8000 Bug in loc raised for numeric label even when label is in Index by phofl · Pull Request #37675 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

Bug in loc raised for numeric label even when label is in Index #37675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify if else conditions
  • Loading branch information
phofl committed Nov 8, 2020
commit 7ecd86ccc5f68bf0ec7569ae5298bbdf619a6d8b
8 changes: 1 addition & 7 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5201,13 +5201,7 @@ def _maybe_cast_slice_bound(self, label, side: str_t, kind):
# wish to have special treatment for floats/ints, e.g. Float64Index and
# datetimelike Indexes
# reject them, if index does not contain label
if is_float(label) and label not in self.values:
self._invalid_indexer("slice", label)

# we are trying to find integer bounds on a non-integer based index
# this is rejected (generally .loc gets you here) if label is not in
# index
elif is_integer(label) and label not in self.values:
if (is_float(label) or is_integer(label)) and label not in self.values:
self._invalid_indexer("slice", label)

return label
Expand Down
0