'How to fix ParserError: Error tokenizing data for CSV pandas

Sample DF(1 column without header name):

vers    2.1.0  
info    days    6
info    x       a
info    y       b 

Here is my code and error message:

df = pd.read_csv("64881_info.csv")
ParserError: Error tokenizing data. C error

I tried to fix:

import pandas as pd
df = pd.read_csv("64881_info.csv", error_bad_lines=False)

It works but column header name shift right by next. Row indexing is not showing also after reading the csv file. How can I fix this?

Output df:

        vers    2.1.0
info    days    6     
info    x       a
info    y       b


Solution 1:[1]

You could try to just skip the bad lines if you don't think there are too many:

df= pd.read_csv('64881_info.csv', on_bad_lines='skip')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cary Cox