成功将csv数据导入python,但许多浮点数转换为对象

时间:2018-03-19 16:50:42

标签: python-2.7 csv

所有

我已经将csv文件导入到python中,但是很多浮点变量都被转换为对象。我已经尝试了不同的方法将它们转换回浮动但它不起作用(不确定为什么?)

data=pd.read_csv("path\filename.csv")
data['x']=data['x'].convert_objects(convert_numeric=True)

data['x'].convert_objects(convert_numeric=True)

我该怎么办?读取数据为txt?或者将其读作excel文件?

1 个答案:

答案 0 :(得分:0)

data[['upload_date','Gross Loan Amount','Loan Amount']]
     upload_date Gross Loan Amount     Loan Amount
0     12/03/2018          864,053      -864,052.77
1     12/03/2018        1,765,824    -1,765,823.78
2     12/03/2018          859,714      -859,713.72
3     12/03/2018       32,400,556   -32,400,556.13
4     12/03/2018          553,856      -553,855.66
5     12/03/2018        2,715,921    -2,715,921.29
6     12/03/2018           54,913       -54,913.32
7     12/03/2018        5,156,250     5,156,250.00
8     12/03/2018       14,190,000    14,190,000.00

upload_date          object
Gross Loan Amount    object
Loan Amount          object
dtype: object