Skip to content

DOC: MultiIndex Indexing Using Slices #5280

Closed
@cancan101

Description

@cancan101

I have the following DataFrame:

    t1  t2
    b1  b1
i1   1   1

which I can index like this:

In [139]: df["t1"]
Out[139]: 
    b1
i1   1

In [140]: df["t1","b1"]
Out[140]: 
i1    1
Name: (t1, b1), dtype: int64

In [141]: df["t1"]["b1"]
Out[141]: 
i1    1
Name: b1, dtype: int64

I would expect this to work, but ti does not:

In [142]: df[:]["b1"]
KeyError: 'b1'

as well as this (which also raises an unhelpful error message):

In [143]: df[:,"b1"]
TypeError: 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions