python - Pandas - 在列表中,python查找每個子列表的大小

  显示原文与译文双语对照的内容

我有一個很大的浮點數和整數列表,如下所示,我想通過忽略空或單個元素來查找每個子列表的長度。


big_list = [[137.83,81.80,198.56],0.0,[200.37,151.55,165.26, 211.84],


 0.0,[1,2,3],4,[5,6,0,5,7,8],0,[2,1,4,5],[9,1,-2]]



我現在的代碼:


list_len = []


for i in big_list: 


 list_len.append(len(i))



當前輸出:


TypeError: object of type 'numpy.float64' has no len() 



預期輸出:


list_len = [3,4,3,6,4,3] # list_len should neglect elements like 0, 4 in big_list. 



时间:

我有一個很大的浮點數和整數列表,如下所示,我想通過忽略空或單個元素來查找每個子列表的長度。


big_list = [[137.83,81.80,198.56],0.0,[200.37,151.55,165.26, 211.84],


 0.0,[1,2,3],4,[5,6,0,5,7,8],0,[2,1,4,5],[9,1,-2]]



我現在的代碼:


list_len = []


for i in big_list: 


 list_len.append(len(i))



當前輸出:


TypeError: object of type 'numpy.float64' has no len() 



預期輸出:


list_len = [3,4,3,6,4,3] # list_len should neglect elements like 0, 4 in big_list. 



我有一個很大的浮點數和整數列表,如下所示,我想通過忽略空或單個元素來查找每個子列表的長度。


big_list = [[137.83,81.80,198.56],0.0,[200.37,151.55,165.26, 211.84],


 0.0,[1,2,3],4,[5,6,0,5,7,8],0,[2,1,4,5],[9,1,-2]]



我現在的代碼:


list_len = []


for i in big_list: 


 list_len.append(len(i))



當前輸出:


TypeError: object of type 'numpy.float64' has no len() 



預期輸出:


list_len = [3,4,3,6,4,3] # list_len should neglect elements like 0, 4 in big_list. 



我有一個很大的浮點數和整數列表,如下所示,我想通過忽略空或單個元素來查找每個子列表的長度。


big_list = [[137.83,81.80,198.56],0.0,[200.37,151.55,165.26, 211.84],


 0.0,[1,2,3],4,[5,6,0,5,7,8],0,[2,1,4,5],[9,1,-2]]



我現在的代碼:


list_len = []


for i in big_list: 


 list_len.append(len(i))



當前輸出:


TypeError: object of type 'numpy.float64' has no len() 



預期輸出:


list_len = [3,4,3,6,4,3] # list_len should neglect elements like 0, 4 in big_list. 



我有一個很大的浮點數和整數列表,如下所示,我想通過忽略空或單個元素來查找每個子列表的長度。


big_list = [[137.83,81.80,198.56],0.0,[200.37,151.55,165.26, 211.84],


 0.0,[1,2,3],4,[5,6,0,5,7,8],0,[2,1,4,5],[9,1,-2]]



我現在的代碼:


list_len = []


for i in big_list: 


 list_len.append(len(i))



當前輸出:


TypeError: object of type 'numpy.float64' has no len() 



預期輸出:


list_len = [3,4,3,6,4,3] # list_len should neglect elements like 0, 4 in big_list. 



...