Skip to content

BUG: Slicing of Index with strings does not raise anymore when keys are not in Index #37810

Closed
@phofl

Description

@phofl

The following

df2 = pd.DataFrame({"A": [1, 2, 3]}, index=['a', 'c', 'b'])
df2.loc['d':'e']

Should raise a KeyError. This worked in the past (see #18531) but does not anymore. Question is if we should raise in slice_locs if start and end are equal or if we should do this after calling the function.

cc @jreback

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugError ReportingIncorrect or improved errors from pandasIndexingRelated to indexing on series/frames, not to indexes themselvesNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions