【Pandas ERROR】 ValueError: cannot convert float NaN to integer

 

报错语句

data['col'] = data['col'].apply(int)

 

报错提示

ValueError: cannot convert float NaN to integer

 

报错原因

因为字段中存在NaN值,所以无法转换为指定类型

 

解决办法

剔除该字段中的NaN值所在的行

 

具体可参考(需要科学上网):https://stackoverflow.com/questions/47333227/pandas-valueerror-cannot-convert-float-nan-to-integer

你可能感兴趣的:(Big,Data,Analysis)