Skip to content

Commit fb2cf0f

Browse files
Backport PR #57057 on branch 2.2.x (COMPAT: Make argsort compatable with numpy 2.0) (#57062)
Backport PR #57057: COMPAT: Make argsort compatable with numpy 2.0 Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 3b833cf commit fb2cf0f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

pandas/compat/numpy/function.py

+2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def validate_argmax_with_skipna(skipna: bool | ndarray | None, args, kwargs) ->
138138
ARGSORT_DEFAULTS["kind"] = "quicksort"
139139
ARGSORT_DEFAULTS["order"] = None
140140
ARGSORT_DEFAULTS["kind"] = None
141+
ARGSORT_DEFAULTS["stable"] = None
141142

142143

143144
validate_argsort = CompatValidator(
@@ -149,6 +150,7 @@ def validate_argmax_with_skipna(skipna: bool | ndarray | None, args, kwargs) ->
149150
ARGSORT_DEFAULTS_KIND: dict[str, int | None] = {}
150151
ARGSORT_DEFAULTS_KIND["axis"] = -1
151152
ARGSORT_DEFAULTS_KIND["order"] = None
153+
ARGSORT_DEFAULTS_KIND["stable"] = None
152154
validate_argsort_kind = CompatValidator(
153155
ARGSORT_DEFAULTS_KIND, fname="argsort", max_fname_arg_count=0, method="both"
154156
)

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ def __array_ufunc__(self, ufunc: np.ufunc, method: str_t, *inputs, **kwargs):
956956
return self.__array_wrap__(result)
957957

958958
@final
959-
def __array_wrap__(self, result, context=None):
959+
def __array_wrap__(self, result, context=None, return_scalar=False):
960960
"""
961961
Gets called after a ufunc and other functions e.g. np.split.
962962
"""

pandas/core/series.py

+3
Original file line numberDiff line numberDiff line change
@@ -4066,6 +4066,7 @@ def argsort(
40664066
axis: Axis = 0,
40674067
kind: SortKind = "quicksort",
40684068
order: None = None,
4069+
stable: None = None,
40694070
) -> Series:
40704071
"""
40714072
Return the integer indices that would sort the Series values.
@@ -4082,6 +4083,8 @@ def argsort(
40824083
information. 'mergesort' and 'stable' are the only stable algorithms.
40834084
order : None
40844085
Has no effect but is accepted for compatibility with numpy.
4086+
stable : None
4087+
Has no effect but is accepted for compatibility with numpy.
40854088
40864089
Returns
40874090
-------

0 commit comments

Comments
 (0)