Skip to content

BUG: loc/ix indexers with empty list key lose names of respective axes #6552

Closed
@immerrr

Description

@immerrr

This issue was encountered when fixing #6536. It seems that .loc indexer with empty list key seems to lose names of respective axes:

In [2]: pd.DataFrame(np.arange(9).reshape(3,3), columns=pd.Series(list('abc'), name='foobar'))
Out[2]: 
foobar  a  b  c
0       0  1  2
1       3  4  5
2       6  7  8

[3 rows x 3 columns]

In [3]: _2.iloc[:,[]]
Out[3]: 
Empty DataFrame
Columns: []
Index: [0, 1, 2]

[3 rows x 0 columns]

In [4]: _2.iloc[:,[]].columns.names
Out[4]: FrozenList([u'foobar'])

In [5]: _2.loc[:,[]].columns.names
Out[5]: FrozenList([None])

It's not important, but currently #6551 has two tests skipped because of this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesInternalsRelated to non-user accessible pandas implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions