从the Wikipedia pageon college towns是美国大学城的一个列表,它被复制并粘贴到university_towns.txt
文件中。你知道吗
我使用pandas.read_csv('university_towns.txt')
读取文件,但得到CParserError
消息。你知道吗
我也尝试设置error_bad_lines=False
,但它会导致一些数据丢失。你知道吗
CParserError: Error tokenizing data. C error: Expected 1 fields in line 8,saw 3
不清楚粘贴到
university_towns.txt
后对列表引入了哪些更改。不过,快速查看一下列表可以发现,许多大学的名称都包含逗号,
。这就是导致pandas.read_csv
失败的原因这是因为,正如在
pandas.read_csv
documentation中所解释的,逗号被用作默认分隔符","
。快速解决方法是按以下步骤更换分离器:相关问题 更多 >
编程相关推荐