Fix the ParserError in Python: Error tokenizing data. C error: Expected N fields in line (2 Examples)

On this page you’ll learn how to deal with the “ParserError: Error tokenizing data. C error: Expected X fields in line Y, saw Z” in the Python programming language.

Example 1: Replicating the ParserError: Error tokenizing data. C error: Expected N fields in line

my_df = pd.read_csv('my_df.csv')                           # Reading CSV file does not work
# ParserError: Error tokenizing data. C error: Expected 4 fields in line 5, saw 5

Example 2: Fixing the ParserError: Error tokenizing data. C error: Expected N fields in line

my_df = pd.read_csv('my_df.csv', error_bad_lines = False)  # Remove rows with errors

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top