@@ -180,7 +180,7 @@ class ExtensionArray:
180
180
* dropna
181
181
* unique
182
182
* factorize / _values_for_factorize
183
- * argsort / _values_for_argsort
183
+ * argsort, argmax, argmin / _values_for_argsort
184
184
* searchsorted
185
185
186
186
The remaining methods implemented on this class should be performant,
@@ -639,7 +639,7 @@ def _values_for_argsort(self) -> np.ndarray:
639
639
This means that the corresponding entries in the returned array don't need to
640
640
be modified to sort correctly.
641
641
"""
642
- # Note: this is used in `ExtensionArray.argsort`.
642
+ # Note: this is used in `ExtensionArray.argsort/argmin/argmax `.
643
643
return np .array (self )
644
644
645
645
def argsort (
@@ -676,7 +676,8 @@ def argsort(
676
676
# Implementor note: You have two places to override the behavior of
677
677
# argsort.
678
678
# 1. _values_for_argsort : construct the values passed to np.argsort
679
- # 2. argsort : total control over sorting.
679
+ # 2. argsort : total control over sorting. In case of overriding this,
680
+ # it is recommended to also override argmax/argmin
680
681
ascending = nv .validate_argsort_with_ascending (ascending , args , kwargs )
681
682
682
683
values = self ._values_for_argsort ()
@@ -707,6 +708,10 @@ def argmin(self, skipna: bool = True) -> int:
707
708
--------
708
709
ExtensionArray.argmax
709
710
"""
711
+ # Implementor note: You have two places to override the behavior of
712
+ # argmin.
713
+ # 1. _values_for_argsort : construct the values used in nargminmax
714
+ # 2. argmin itself : total control over sorting.
710
715
validate_bool_kwarg (skipna , "skipna" )
711
716
if not skipna and self ._hasna :
712
717
raise NotImplementedError
@@ -731,6 +736,10 @@ def argmax(self, skipna: bool = True) -> int:
731
736
--------
732
737
ExtensionArray.argmin
733
738
"""
739
+ # Implementor note: You have two places to override the behavior of
740
+ # argmax.
741
+ # 1. _values_for_argsort : construct the values used in nargminmax
742
+ # 2. argmax itself : total control over sorting.
734
743
validate_bool_kwarg (skipna , "skipna" )
735
744
if not skipna and self ._hasna :
736
745
raise NotImplementedError
0 commit comments