-1

Pandas in the read_csv() in type error shown as:

TypeError                                 Traceback (most recent call last)
Cell In[30], line 1
----> 1 pd.read_csv('Datasets/BX-Books.csv', sep=';',encoding='latin-1',error_bad_lines=False)

TypeError: read_csv() got an unexpected keyword argument 'error_bad_lines'

I have trying to run code is usaally in error_bad_lines parameter and run the code:

pd.read_csv('Datasets/BX-Books.csv', sep=';',encoding='latin-1',error_bad_lines=False)

but pandas old version is running and work but why do not work it and through error:

TypeError                                 Traceback (most recent call last)
Cell In[30], line 1
----> 1 pd.read_csv('Datasets/BX-Books.csv', sep=';',encoding='latin-1',error_bad_lines=False)

TypeError: read_csv() got an unexpected keyword argument 'error_bad_lines'

1 Answer 1

0

According to the documentation this argument is deprecated and it was replaced by on_bad_lines argument. Here is the detail for this new argument :

on_bad_lines{‘error’, ‘warn’, ‘skip’} or Callable, default ‘error’

Specifies what to do upon encountering a bad line (a line with too many fields). Allowed values are :

'error', raise an Exception when a bad line is encountered.

'warn', raise a warning when a bad line is encountered and skip that line.

'skip', skip bad lines without raising or warning when they are encountered.

So you can use this parameter instead, here is an example of using this parameter in your code :

pd.read_csv('Datasets/BX-Books.csv', sep=';',encoding='latin-1',on_bad_lines='skip')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.