首页 > 解决方案 > How to delete the list that constitute "nan"

问题描述

I have data that is taken from excel sheet using data=pd.read_excel("test.xlsx").to_dict() function. I made several changes on data taken from that function and created such an list

[[0, nan], [1, nan], [2, nan], [3, nan], [4, nan], [5, nan], [6, nan], [7, nan], [8, nan], [9, nan], [10, nan], [11, nan]]

When I try to remove each element that constitute "nan", gives me error that is shown as below

for listinside in list2:
if 'nan' in listinside[1]:
    listinside.remove()
else:
    pass
print(list2)

TypeError: argument of type 'float' is not iterable

I kindly ask you to help me to remove each element from entire list that constitute 'nan'.

标签: pythonpandaslist

解决方案


推荐阅读