python-3.x - 转换成浮点数据后变成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 - 带有自动轮换密码数据库的 Django 连接
- phpwebsocket - PHP:无法连接到 francium diffsocket
- r - 无法在 R 中加载 shapefile“错误:未找到功能”
- android - 如何使用 Content Resolver 从图库中的图像中获取路径数据
- c# - 如果值为空,则使用 Dapper 返回日期
- javascript - 如何在使用 Slim 的 html 标签中添加带有 id 的 javascript 代码?
- wpf - 事件处理程序未在属性更改时触发
- javascript - 如何更改数据表中的行颜色?
- python - 如何从值元组创建 lambda 函数
- sql-server - 如何为存储过程的结果生成创建表