Skip to content

read_csv uses deprecated pandas arguments (squeeze, error_bad_lines) #78

Description

@NishaKushwah2004

Problem

The notebook working-with-csv.ipynb uses deprecated pandas arguments in pd.read_csv().

Examples found in the notebook:

  • squeeze=True
  • error_bad_lines=False

These parameters have been removed in pandas >= 2.0, which causes the following errors:

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

Location

File: working-with-csv.ipynb

Suggested Fix

Update the deprecated arguments to their modern alternatives.

Replace:

pd.read_csv('aug_train.csv', usecols=['gender'], squeeze=True)

with:

pd.read_csv('aug_train.csv', usecols=['gender'])['gender']

and replace:

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

with:

pd.read_csv('BX-Books.csv', sep=';', encoding='latin-1', on_bad_lines='skip')

This will ensure compatibility with pandas 2.x.

I would be happy to submit a pull request implementing this fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions