Skip to content

Slicing a dataframe for rows by set of index labels returns empty rows for missing labels, feature or bug? #2911

Closed
@ruidc

Description

@ruidc

what is the best way to safely slice using multiple index labels? (i.e. not create new NaN rows?) is the best way to do this to intersect the index with the searched values before searching?

import pandas
df = pandas.DataFrame([[1,2], [3,4]], index=['X', 'Y'], columns=['A', 'B'])
df.ix[['X', 'Z'], :]

Out[1]: 
    A   B
X   1   2
Z NaN NaN    < -- why does this not error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDuplicate ReportDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions