2
我指的是這個問題。將pandas dataframe列導入爲字符串,不是int或float
ID
00013007854817840016671868
00013007854817840016749251
00013007854817840016754630
00013007854817840016781876
00013007854817840017028824
00013007854817840017963235
00013007854817840018860166
df = read_csv('sample.csv')
df.ID
>>
0 -9223372036854775808
1 -9223372036854775808
2 -9223372036854775808
3 -9223372036854775808
4 -9223372036854775808
5 -9223372036854775808
6 -9223372036854775808
Name: ID
提出的解決方案是這樣的:
read_csv('sample.csv', dtype={'ID': object})
但是,如果我想整個csv
文件將被解讀爲str
列,而不是int
什麼?爲每一列提供一本詞典將是極其重要的。有沒有更清潔的方法?