Skip to content
Merged
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
15 changes: 12 additions & 3 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class ExtensionArray:
* dropna
* unique
* factorize / _values_for_factorize
* argsort / _values_for_argsort
* argsort, argmax, argmin / _values_for_argsort
* searchsorted

The remaining methods implemented on this class should be performant,
Expand Down Expand Up @@ -639,7 +639,7 @@ def _values_for_argsort(self) -> np.ndarray:
This means that the corresponding entries in the returned array don't need to
be modified to sort correctly.
"""
# Note: this is used in `ExtensionArray.argsort`.
# Note: this is used in `ExtensionArray.argsort/argmin/argmax`.
return np.array(self)

def argsort(
Expand Down Expand Up @@ -676,7 +676,8 @@ def argsort(
# Implementor note: You have two places to override the behavior of
# argsort.
# 1. _values_for_argsort : construct the values passed to np.argsort
# 2. argsort : total control over sorting.
# 2. argsort : total control over sorting. In case of overriding this,
# it is recommended to also override argmax/argmin
ascending = nv.validate_argsort_with_ascending(ascending, args, kwargs)

values = self._values_for_argsort()
Expand Down Expand Up @@ -707,6 +708,10 @@ def argmin(self, skipna: bool = True) -> int:
--------
ExtensionArray.argmax
"""
# Implementor note: You have two places to override the behavior of
# argmin.
# 1. _values_for_argsort : construct the values used in nargminmax
# 2. argmin itself : total control over sorting.
validate_bool_kwarg(skipna, "skipna")
if not skipna and self._hasna:
raise NotImplementedError
Expand All @@ -731,6 +736,10 @@ def argmax(self, skipna: bool = True) -> int:
--------
ExtensionArray.argmin
"""
# Implementor note: You have two places to override the behavior of
# argmax.
# 1. _values_for_argsort : construct the values used in nargminmax
# 2. argmax itself : total control over sorting.
validate_bool_kwarg(skipna, "skipna")
if not skipna and self._hasna:
raise NotImplementedError
Expand Down