14

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?

smci
  • 32,567
  • 20
  • 113
  • 146
Atharva Katre
  • 457
  • 1
  • 6
  • 17

1 Answers1

36

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')
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Corralien
  • 109,409
  • 8
  • 28
  • 52
  • Thanks for the answer. Just to make it even more clear, if you use `error_bad_lines` and `warn_bad_lines`, both should be replaced by `on_bad_lines`. – ruhanbidart Jul 08 '22 at 18:58
  • 2
    @ruhanbidart. Right you can replace `error_bad_lines=True` by `on_bad_lines='error'` and `warn_bad_lines=True` by `on_bad_lines='warn'` – Corralien Jul 08 '22 at 21:49
  • 1
    Thanx for this excellent punchline ;-) – Laurent B. Feb 07 '23 at 00:26