Skip to content

BUG: reindex with empty inputs #27326

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

Closed
Changes from all commits
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
5 changes: 4 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3019,7 +3019,7 @@ def _get_fill_indexer(self, target, method, limit=None, tolerance=None):
indexer = method(target._ndarray_values, limit)
else:
indexer = self._get_fill_indexer_searchsorted(target, method, limit)
if tolerance is not None:
if tolerance is not None and len(self):
indexer = self._filter_indexer_tolerance(
target._ndarray_values, indexer, tolerance
)
Expand Down Expand Up @@ -3062,6 +3062,9 @@ def _get_nearest_indexer(self, target, limit, tolerance):
values that can be subtracted from each other (e.g., not strings or
tuples).
"""
if len(self) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use not len

return self._get_fill_indexer(target, None)

left_indexer = self.get_indexer(target, "pad", limit=limit)
right_indexer = self.get_indexer(target, "backfill", limit=limit)

Expand Down