- 问题描述
- 原因分析
- 解决办法
- 参考
ValueError: cannot convert float NaN to integer
Google发现原因是(百度找不到):
原因分析NaN is short for Not a Number . It is a numeric data type used to represent any value that is undefined or unpresentable. The ValueError: cannot convert float NaN to integer raised because of Pandas doesn’t have the ability to store NaN values for integers.
Nan是没有数字的缩写。它是一种数字数据类型,用于表示任何不确定或无法说明的值。值:由于pandas没有能力为整数存储NAN值,因此无法将float nan转换为增加的整数。
数组是整数,不能给整数数组赋np.nan值。
解决办法最简单的办法是先将数组转换为float类型,再进行赋值操作。但之后不能转回int类型,会出问题,broadcast广播出错,暂不知为何,还请高人指点!
Google搜索ValueError: cannot convert float NaN to integer



