我想以字符串的形式导入下面的 csv,而不是 int64。熊猫 read _ csv 会自动将其转换为 int64,但是我需要这个列作为字符串。
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
不幸的是,使用转换器也会得到同样的结果。
df = read_csv('sample.csv', converters={'ID': str})
df.ID
>>
0 -9223372036854775808
1 -9223372036854775808
2 -9223372036854775808
3 -9223372036854775808
4 -9223372036854775808
5 -9223372036854775808
6 -9223372036854775808
Name: ID