Skip to content

false positive E1137 on pandas dataframe column assignment when set_index() is used #7564

@jmrouet

Description

@jmrouet

Bug description

pylint: disable=missing-module-docstring,invalid-name

import pandas as pd

df = pd.DataFrame([{'id': 0, 'name': 'test'}]).set_index('id')
df['newcolumn'] = 'foo'
print(df)

Configuration

No response

Command used

pylint test2.py

Pylint output

************* Module test2
test2.py:5:0: E1137: 'df' does not support item assignment (unsupported-assignment-operation)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior


Your code has been rated at 10.00/10 (previous run: 0.00/10, +10.00)

Pylint version

pylint 2.15.2
astroid 2.12.9
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:51:29) [MSC v.1929 64 bit (AMD64)]

OS / Environment

Windows 11

Additional dependencies

pandas==1.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeHelp wanted 🙏Outside help would be appreciated, good for new contributorsLib specific 💅This affect the code from a particular libraryNeeds astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions