Skip to content

DataFrame.index setter is very restrictive compared to DataFrame.columns #1366

@loicdiridollou

Description

@loicdiridollou

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
  2. Indicate which type checker you are using (mypy or pyright).
  3. Show the error message received from that type checker while checking your example.
import pandas as pd

df = pd.DataFrame(data={"col1": [1, 2], "col2": [3, 4]})
df.index = [3, 4]

Error message is:

Cannot assign to attribute "index" for class "DataFrame"   "list[int]" is not assignable to "Index[Any]"

Please complete the following information:

  • OS: MacOS
  • OS Version 15
  • python version 3.13
  • version of type checker 1.17.1
  • version of installed pandas-stubs main

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions