Not finding an attr and generating attr-defined error
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Generates a [attr-defined] error claiming the attr doesnot exists.
To Reproduce
import pandas as pd
tmp_df = pd.DataFrame(data={
"c1": [1, 2, 3, 4],
"c2": [5, 6, 7, 8]
})
if any(tmp_df.index.diff()[1:] <= 0):
print("ohoh")
Expected Behavior
No error should be produced
Actual Behavior
error: "Index[Any]" has no attribute "diff" [attr-defined]
if any(tmp_df.index.diff()[1:] <= 0):
^~~~~~~~~~~~~~~~~
Your Environment
python=3.11
pandas
pandas-stubs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided Python 3.11 reproduction with pandas and pandas-stubs, then inspect why tmp_df.index is typed as Index[Any] instead of exposing diff(). Done means the valid call no longer emits an attr-defined error and the reproduction is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- pandas, python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100