Issue
So basically I have a csv file which consists of two columns in which the data are Cinema name and prices respectively. (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 )
I firstly tried normal read_csv
df.read_csv('file')
But it turned out that the float64 was parsed as Object, which is not what I want.
I read this post
, but the solution there is assuming they know the column name and datatype in that column.
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 ?
Note I only want to handle ',' only for float Data not String data.
Thanks for your helps..
Solution
Pandas read_csv
function has a thousands
argument, which you can specify to be ,
instead of the default .
df.read_csv('file', thousands=',')
Answered By - rafaelc Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.