From b7353176eb5ec15873226cf85ed1a2afcd08da09 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 29 Jun 2021 10:10:55 -0700 Subject: [PATCH 1/2] BUG: don't silently ignore kwargs in get_indexer_for --- doc/source/whatsnew/v1.4.0.rst | 2 +- pandas/core/indexes/base.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 81545ada63ce5..0cd7105793351 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -87,7 +87,7 @@ See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for mor Other API changes ^^^^^^^^^^^^^^^^^ -- +- :meth:`Index.get_indexer_for` no longer accepts keyword arguments (other than 'target'); in the past these would be silently ignored if the index was not unique (:issue:`??`) - .. --------------------------------------------------------------------------- diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 3cfa1f15fa118..495d7c2d91896 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -5293,7 +5293,7 @@ def get_indexer_non_unique(self, target) -> tuple[np.ndarray, np.ndarray]: return ensure_platform_int(indexer), ensure_platform_int(missing) @final - def get_indexer_for(self, target, **kwargs) -> np.ndarray: + def get_indexer_for(self, target) -> np.ndarray: """ Guaranteed return of an indexer even when non-unique. @@ -5306,7 +5306,7 @@ def get_indexer_for(self, target, **kwargs) -> np.ndarray: List of indices. """ if self._index_as_unique: - return self.get_indexer(target, **kwargs) + return self.get_indexer(target) indexer, _ = self.get_indexer_non_unique(target) return indexer From 23d49cac6bef4e3358966d9d931c207fc3e6eae0 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 29 Jun 2021 10:12:35 -0700 Subject: [PATCH 2/2] GH ref --- doc/source/whatsnew/v1.4.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 0cd7105793351..31e9a3d9873b2 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -87,7 +87,7 @@ See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for mor Other API changes ^^^^^^^^^^^^^^^^^ -- :meth:`Index.get_indexer_for` no longer accepts keyword arguments (other than 'target'); in the past these would be silently ignored if the index was not unique (:issue:`??`) +- :meth:`Index.get_indexer_for` no longer accepts keyword arguments (other than 'target'); in the past these would be silently ignored if the index was not unique (:issue:`42310`) - .. ---------------------------------------------------------------------------