Skip to content

REF: de-duplicate get_indexer_non_unique #36322

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 4 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2512,10 +2512,6 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):

return ensure_platform_int(indexer)

@Appender(_index_shared_docs["get_indexer_non_unique"] % _index_doc_kwargs)
def get_indexer_non_unique(self, target):
return super().get_indexer_non_unique(target)

def get_slice_bound(
self, label: Union[Hashable, Sequence[Hashable]], side: str, kind: str
) -> int:
Expand Down
19 changes: 3 additions & 16 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pandas.util._decorators import Appender, cache_readonly, doc

from pandas.core.dtypes.common import (
ensure_platform_int,
is_bool_dtype,
is_datetime64_any_dtype,
is_dtype_equal,
Expand Down Expand Up @@ -473,12 +472,13 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):
target = ensure_index(target)

if isinstance(target, PeriodIndex):
if target.freq != self.freq:
if not self._is_comparable_dtype(target.dtype):
# i.e. target.freq != self.freq
# No matches
no_matches = -1 * np.ones(self.shape, dtype=np.intp)
return no_matches

target = target.asi8
target = target._get_engine_target() # i.e. target.asi8
self_index = self._int64index
else:
self_index = self
Expand All @@ -491,19 +491,6 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):

return Index.get_indexer(self_index, target, method, limit, tolerance)

@Appender(_index_shared_docs["get_indexer_non_unique"] % _index_doc_kwargs)
def get_indexer_non_unique(self, target):
target = ensure_index(target)

if not self._is_comparable_dtype(target.dtype):
no_matches = -1 * np.ones(self.shape, dtype=np.intp)
return no_matches, no_matches

target = target.asi8

indexer, missing = self._int64index.get_indexer_non_unique(target)
return ensure_platform_int(indexer), missing

def get_loc(self, key, method=None, tolerance=None):
"""
Get integer location for requested label.
Expand Down