Closed
Description
Using a tuple as the key for DataFrame.loc
returns ScalarType
.
from pandas import MultiIndex, DataFrame
index = MultiIndex.from_tuples([(0, 0), (0, 1)])
df = DataFrame(range(2), index=index)
key = (0, 0)
x = df.loc[key].copy() # raises [union-attr] Item has no attribute "copy"
I think the issue is these lines, that seem to just flatout make wrong assumptions in case when the DataFrame is equipped with a MultiIndex
:
pandas-stubs/pandas-stubs/core/frame.pyi
Lines 159 to 170 in 68780c7
Please complete the following information:
- python version 3.10.6
- version of type checker mypy 0.991
- version of installed
pandas-stubs
1.5.2.221124
Metadata
Metadata
Assignees
Labels
No labels