如何强制pandas read_csv忽略实际分隔符之间的分号?
在csv中,您有以下内容-正如您在第三行中看到的,第二列有一个分号-如何强制pandas read_csv忽略实际分隔符之间的分号?,csv,pandas,dataframe,delimiter,Csv,Pandas,Dataframe,Delimiter,在csv中,您有以下内容-正如您在第三行中看到的,第二列有一个分号- /path/to/file,2,9/15/2016 /path/to/file,3,9/15/2016 /path/to/file,2;3,9/15/2016 因此,pandas read_csv将该分号视为分隔符(即使我指定sep=','),您将得到- /path/to/file 2 9/15/2016 /path/to/file 2 9/15/2016 /
/path/to/file,2,9/15/2016
/path/to/file,3,9/15/2016
/path/to/file,2;3,9/15/2016
因此,pandas read_csv将该分号视为分隔符(即使我指定sep=','),您将得到-
/path/to/file 2 9/15/2016
/path/to/file 2 9/15/2016
/path/to/file 2 3 9/15/2016
如何使read_csv忽略分号?谢谢 您还可以提供您的代码吗? 我已经创建了以下csv和py文件,代码中没有分隔符,它工作正常 info.csv
path,number,date
/path/to/file,2,9/15/2016
/path/to/file,3,9/15/2016
/path/to/file,2;3,9/15/2016
test.py
import pandas
t = pandas.read_csv('info.csv')
print(t)
这是输出:
path number date
0 /path/to/file 2 9/15/2016
1 /path/to/file 3 9/15/2016
2 /path/to/file 2;3 9/15/2016