Closed
Description
Hi,
Describe the bug
The type returned by DataFrame.index
and DataFrame.columns
is, respectively, Index
and Index[str]
. This is invalid when the dataframe uses MultiIndex for their index and/or columns
To Reproduce
1.
import numpy as np
import pandas as pd
df = pd.DataFrame(
np.arange(6).reshape((3, 2)),
index=pd.MultiIndex.from_product((("i",), ("j1", "j2", "j3"))),
columns=pd.MultiIndex.from_product((("a",), ("b1", "b2"))),
)
idx = df.index # type show as Index
cols = df.columns # type shown as Index[str]
- pyright version 1.1.373, commit ee424479
- None. Just check the type revealed for
idx
andcols
, doesn't match the expected multiindex
Please complete the following information:
- Windows 11
- python version 3.12.5
- pyright version 1.1.373
- pandas-stubs Version: 2.2.2.240807
Additional context
Properties implemented in
pandas-stubs/pandas-stubs/core/frame.pyi
Line 1519 in b246fcf
pandas-stubs/pandas-stubs/core/frame.pyi
Line 1533 in b246fcf
Getters should be updated too I guess, not sure if this should be a specific issue
Metadata
Metadata
Assignees
Labels
No labels