空值补0一直报错,不知带什么情况,有没有哥帮忙解答一下谢谢。
代码如下
for i in train.columns:
for j in train.index:
if np.isnan(train[i][j]):
train[i][j] = 0
报错
Traceback (most recent call last):
File "C:\Users\zr041\Desktop\test\happiness.py", line 40, in <module>
if np.isnan(train[i][j]):
^^^^^^^^^^^^^^^^^^^^^
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Process finished with exit code 1
数据类型如下:
id happiness ... public_service_8 public_service_9
0 1 4 ... 50 50
1 2 4 ... 60 60
2 3 4 ... 90 75
3 4 5 ... 80 80
4 5 4 ... 50 50