Skip to content

Commit 7368686

Browse files
authored
COMPAT: Make argsort compatable with numpy 2.0 (#57057)
Make argsort compatable with numpy 2.0
1 parent aaa2760 commit 7368686

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
@@ -958,7 +958,7 @@ def __array_ufunc__(self, ufunc: np.ufunc, method: str_t, *inputs, **kwargs):
958958
return self.__array_wrap__(result)
959959

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

pandas/core/series.py

+3
Original file line numberDiff line numberDiff line change
@@ -4070,6 +4070,7 @@ def argsort(
40704070
axis: Axis = 0,
40714071
kind: SortKind = "quicksort",
40724072
order: None = None,
4073+
stable: None = None,
40734074
) -> Series:
40744075
"""
40754076
Return the integer indices that would sort the Series values.
@@ -4086,6 +4087,8 @@ def argsort(
40864087
information. 'mergesort' and 'stable' are the only stable algorithms.
40874088
order : None
40884089
Has no effect but is accepted for compatibility with numpy.
4090+
stable : None
4091+
Has no effect but is accepted for compatibility with numpy.
40894092
40904093
Returns
40914094
-------

0 commit comments

Comments
 (0)