Skip to content

Commit 4e01bcf

Browse files
Damodara PudduDamodara Puddu
Damodara Puddu
authored and
Damodara Puddu
committed
DOC: Corrected Out-of-date list of sort algorithms
Reference Issues/PRs Fixes: #38287 Implemented changes: Changed the docstring of all the methods using np.sort as it now includes one additional stable algorithm
1 parent d201fcc commit 4e01bcf

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

pandas/core/arrays/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def argsort(
561561
ascending : bool, default True
562562
Whether the indices should result in an ascending
563563
or descending sort.
564-
kind : {'quicksort', 'mergesort', 'heapsort'}, optional
564+
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional
565565
Sorting algorithm.
566566
*args, **kwargs:
567567
Passed through to :func:`numpy.argsort`.

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ def argsort(self, ascending=True, kind="quicksort", **kwargs):
14841484
ascending : bool, default True
14851485
Whether the indices should result in an ascending
14861486
or descending sort.
1487-
kind : {'quicksort', 'mergesort', 'heapsort'}, optional
1487+
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional
14881488
Sorting algorithm.
14891489
**kwargs:
14901490
passed through to :func:`numpy.argsort`.

pandas/core/frame.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5526,9 +5526,9 @@ def sort_index(
55265526
sort direction can be controlled for each level individually.
55275527
inplace : bool, default False
55285528
If True, perform operation in-place.
5529-
kind : {'quicksort', 'mergesort', 'heapsort'}, default 'quicksort'
5530-
Choice of sorting algorithm. See also ndarray.np.sort for more
5531-
information. `mergesort` is the only stable algorithm. For
5529+
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort'
5530+
Choice of sorting algorithm. See also :func:`numpy.sort` for more
5531+
information. `mergesort` and `stable` are the only stable algorithms. For
55325532
DataFrames, this option is only applied when sorting on a single
55335533
column or label.
55345534
na_position : {'first', 'last'}, default 'last'

pandas/core/generic.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4383,11 +4383,11 @@ def sort_values(
43834383
the by.
43844384
inplace : bool, default False
43854385
If True, perform operation in-place.
4386-
kind : {'quicksort', 'mergesort', 'heapsort'}, default 'quicksort'
4387-
Choice of sorting algorithm. See also ndarray.np.sort for more
4388-
information. `mergesort` is the only stable algorithm. For
4389-
DataFrames, if sorting by multiple columns or labels, this
4390-
argument is ignored, defaulting to a stable sorting algorithm.
4386+
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort'
4387+
Choice of sorting algorithm. See also :func:`numpy.sort` for more
4388+
information. `mergesort` and `stable` are the only stable algorithms. For
4389+
DataFrames, this option is only applied when sorting on a single
4390+
column or label.
43914391
na_position : {'first', 'last'}, default 'last'
43924392
Puts NaNs at the beginning if `first`; `last` puts NaNs at the
43934393
end.

pandas/core/series.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -3066,9 +3066,9 @@ def sort_values(
30663066
If True, sort values in ascending order, otherwise descending.
30673067
inplace : bool, default False
30683068
If True, perform operation in-place.
3069-
kind : {'quicksort', 'mergesort' or 'heapsort'}, default 'quicksort'
3069+
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort'
30703070
Choice of sorting algorithm. See also :func:`numpy.sort` for more
3071-
information. 'mergesort' is the only stable algorithm.
3071+
information. 'mergesort' and 'stable' are the only stable algorithms.
30723072
na_position : {'first' or 'last'}, default 'last'
30733073
Argument 'first' puts NaNs at the beginning, 'last' puts NaNs at
30743074
the end.
@@ -3279,9 +3279,9 @@ def sort_index(
32793279
sort direction can be controlled for each level individually.
32803280
inplace : bool, default False
32813281
If True, perform operation in-place.
3282-
kind : {'quicksort', 'mergesort', 'heapsort'}, default 'quicksort'
3282+
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort'
32833283
Choice of sorting algorithm. See also :func:`numpy.sort` for more
3284-
information. 'mergesort' is the only stable algorithm. For
3284+
information. 'mergesort' and 'stable' are the only stable algorithms. For
32853285
DataFrames, this option is only applied when sorting on a single
32863286
column or label.
32873287
na_position : {'first', 'last'}, default 'last'
@@ -3420,9 +3420,9 @@ def argsort(self, axis=0, kind="quicksort", order=None) -> "Series":
34203420
----------
34213421
axis : {0 or "index"}
34223422
Has no effect but is accepted for compatibility with numpy.
3423-
kind : {'mergesort', 'quicksort', 'heapsort'}, default 'quicksort'
3424-
Choice of sorting algorithm. See np.sort for more
3425-
information. 'mergesort' is the only stable algorithm.
3423+
kind : {'mergesort', 'quicksort', 'heapsort', 'stable'}, default 'quicksort'
3424+
Choice of sorting algorithm. See :func:`numpy.sort` for more
3425+
information. 'mergesort' and 'stable' are the only stable algorithms.
34263426
order : None
34273427
Has no effect but is accepted for compatibility with numpy.
34283428

pandas/core/sorting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_indexer_indexer(
5454
target : Index
5555
level : int or level name or list of ints or list of level names
5656
ascending : bool or list of bools, default True
57-
kind : {'quicksort', 'mergesort', 'heapsort'}, default 'quicksort'
57+
kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, default 'quicksort'
5858
na_position : {'first', 'last'}, default 'last'
5959
sort_remaining : bool, default True
6060
key : callable, optional

0 commit comments

Comments
 (0)