Skip to content

BUG: don't silently ignore kwargs in get_indexer_for #42310

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 2 commits into from
Jul 1, 2021
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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:`42310`)
-

.. ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down