[英]how to handle decimal separator in float using Pandas?
So basically I have a csv file which consists of two columns in which the data are Cinema name and prices respectively.所以基本上我有一个 csv 文件,它由两列组成,其中数据分别是电影院名称和价格。 (data in Cinema name are all string whereas prices are float64 but may have example like 12,000.0 OR 3,025.54 where I want it to be 12000.0 or 3025.54 )
(电影名称中的数据都是字符串,而价格是 float64,但可能有像12,000.0或3,025.54这样的例子,我希望它是12000.0或3025.54 )
I firstly tried normal read_csv我首先尝试了正常的 read_csv
df.read_csv('file')
But it turned out that the float64 was parsed as Object , which is not what I want.但事实证明float64被解析为Object ,这不是我想要的。 I read this
post
, but the solution there is assuming they know the column name and datatype in that column.我读了这篇
post
,但那里的解决方案假设他们知道该列中的列名和数据类型。
Assuming I don't know what the column name will be, how would I efficiently handle comma separator in float and make it into float instead of object?假设我不知道列名是什么,我将如何有效地处理浮点数中的逗号分隔符并将其变为浮点数而不是 object?
Note I only want to handle ',' only for float Data not String data.请注意,我只想处理“,”,仅用于浮点数据而不是字符串数据。
Thanks for your helps..谢谢你的帮助。。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.