pandas read_csv: The error_bad_lines argument has been deprecated and will be removed in a future version

Viewed 6580

I am trying to read some data which may sometimes have erroneous and bad rows, so as always I passed error_bad_lines=False but the console keeps throwing the deprecation warning on every run. Why is this feature deprecated and is there any other alternative for skipping bad lines?

1 Answers

Read the documentation:

Deprecated since version 1.3.0: The on_bad_lines parameter should be used instead to specify behavior upon encountering a bad line instead.

So, replace:

df = pd.read_csv(..., error_bad_lines=False)

with:

df = pd.read_csv(..., on_bad_lines='skip')
Related