Pandas skipping lines (stop warnings from showing)

Question:

I am reading a CSV file in Python this way using Pandas:

data = pd.read_csv('file1.csv', error_bad_lines=False)

I am getting:

Skipping line 6: expected 4 fields, saw 6

How do I stop this warnings from showing up?

Asked By: PythonRookie

||

Answers:

From the docs:

data = pd.read_csv('file1.csv', error_bad_lines=False, warn_bad_lines=False)

Answered By: jack6e

From the docs:

warn_bad_lines : boolean, default True

If error_bad_lines is False, and warn_bad_lines is True, a warning for
each “bad line” will be output.

So set warn_bad_lines=False

data = pd.read_csv('file1.csv', error_bad_lines=False, warn_bad_lines=False)
Answered By: EFT
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.