我试图导入一个csv文件(25MB-80000行)到pandas dataframe,但它没有正确显示。调用df.columns
时,列用“;”分隔。在
Originated GeoZone;Booking ...
1 PARIS;PARIS;;MARKer;EQDff;...
2 PARIS;PARIS;;MARKer;EQDff;...
3 PARIS;PARIS;;MARKer;EQDff;...
4 PARIS;PARIS;;MARKer;EQDff;...
csv文件在Excel上非常清晰。为什么熊猫没有很好地解释它呢。在
您应该在}属性:
read_csv
中使用delimiter或{df = pd.read_csv('waka.csv', sep=';')
这个问题可能是由Excel中不同的分隔符引起的,这通常取决于您来自哪个国家。在
你可以试试这个:
这应该行得通。在
理论:这是由csv文件的不同分隔符造成的。Python默认使用逗号,但有些文件可能使用逗号以外的内容,例如:“;”或“|”。在
解决方案:
正如@rafalc指出的,默认的分隔符是
;
,因此必须单独指定它相关问题 更多 >
编程相关推荐