Python Pandas Error tokenizing data

后端 未结 30 2887
不知归路
不知归路 2020-11-22 04:49

I\'m trying to use pandas to manipulate a .csv file but I get this error:

pandas.parser.CParserError: Error tokenizing data. C error: Expected 2 field

30条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 05:34

    Your CSV file might have variable number of columns and read_csv inferred the number of columns from the first few rows. Two ways to solve it in this case:

    1) Change the CSV file to have a dummy first line with max number of columns (and specify header=[0])

    2) Or use names = list(range(0,N)) where N is the max number of columns.

提交回复
热议问题