Skip to content

API: single-level MultiIndex vs Index behavior mismatch #49215

Open
@jbrockmendel

Description

@jbrockmendel
df = pd.DataFrame({"a": [1], "b": [2]})
df2 = df.copy()
cols = pd.MultiIndex.from_arrays([df.columns])
df2.columns = cols

>>> df
   a  b
0  1  2
>>> df2
   a  b
0  1  2

>>> df["a"]
0    1
Name: a, dtype: int64
>>> df2["a"]
   a
0  1

These should behave the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions