首页 > 解决方案 > 转换成浮点数据后变成NaN

问题描述

所以我尝试将对象转换为浮点 cvs 文件,但是当我在 python 中打印时它变成了 NaN

我在互联网上搜索,我无法解决它

继承我的代码 df["tanggal"]= df["tanggal"].str.replace(',','.','-',':','/','').astype(float) 和继承我在 cvs 中的数据

tanggal,data
1998/04/20 16:02:02.129,0.300199 12.772 2.034
1998/04/20 16:02:03.929,0.43372 10.263 2.743
1998/04/20 16:02:10.930,0.299712 5.97 1.447
1998/04/20 16:02:13.430,0.354663 8.425 2.034
1998/04/20 16:02:19.230,1.945443 2.743 1.34
1998/04/20 16:02:23.131,0.389088 3.445 1.34
1998/04/20 16:02:27.631,0.300199 12.772 2.034
1998/04/20 16:02:29.531,11.467904 12.772 1.447
1998/04/20 16:02:33.531,14.617618 7.04 1.703
1998/04/20 16:02:45.532,10.779831 12.772 1.447
1998/04/20 16:02:52.733,0.229358 12.772 1.447
1998/04/20 16:03:16.335,2.442311 12.772 3.445
1998/04/20 16:03:18.035,8.944965 12.772 1.447
1998/04/20 16:03:21.935,0.229358 12.772 1.447


I expeceted to convert it into float

标签: python-3.xpandasmatplotlib

解决方案


推荐阅读