Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

pandas

csv

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?

like image 384
Atharva Katre Avatar asked Sep 07 '25 00:09

Atharva Katre


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')
like image 112
Corralien Avatar answered Sep 09 '25 15:09

Corralien