File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -948,7 +948,7 @@ def value_counts_internal(
948948 result = Series (counts , index = idx , name = name , copy = False )
949949
950950 if sort :
951- result = result .sort_values (ascending = ascending )
951+ result = result .sort_values (ascending = ascending , kind = "stable" )
952952
953953 if normalize :
954954 result = result / counts .sum ()
Original file line number Diff line number Diff line change @@ -993,7 +993,12 @@ def value_counts(
993993 If True then the object returned will contain the relative
994994 frequencies of the unique values.
995995 sort : bool, default True
996- Sort by frequencies when True. Preserve the order of the data when False.
996+ Stable sort by frequencies when True. Preserve the order of the data
997+ when False.
998+
999+ .. versionchanged:: 3.0.0
1000+
1001+ Prior to 3.0.0, the sort was unstable.
9971002 ascending : bool, default False
9981003 Sort in ascending order.
9991004 bins : int, optional
Original file line number Diff line number Diff line change @@ -7761,11 +7761,16 @@ def value_counts(
77617761 normalize : bool, default False
77627762 Return proportions rather than frequencies.
77637763 sort : bool, default True
7764- Sort by frequencies when True. Preserve the order of the data when False.
7764+ Stable sort by frequencies when True. Preserve the order of the data
7765+ when False.
77657766
77667767 .. versionchanged:: 3.0.0
77677768
77687769 Prior to 3.0.0, ``sort=False`` would sort by the columns values.
7770+
7771+ .. versionchanged:: 3.0.0
7772+
7773+ Prior to 3.0.0, the sort was unstable.
77697774 ascending : bool, default False
77707775 Sort in ascending order.
77717776 dropna : bool, default True
@@ -7875,7 +7880,7 @@ def value_counts(
78757880 counts .name = name
78767881
78777882 if sort :
7878- counts = counts .sort_values (ascending = ascending )
7883+ counts = counts .sort_values (ascending = ascending , kind = "stable" )
78797884 if normalize :
78807885 counts /= counts .sum ()
78817886
Original file line number Diff line number Diff line change @@ -2776,8 +2776,8 @@ def value_counts(
27762776 normalize : bool, default False
27772777 Return proportions rather than frequencies.
27782778 sort : bool, default True
2779- Sort by frequencies when True. When False, non-grouping columns will appear
2780- in the order they occur in within groups.
2779+ Stable sort by frequencies when True. When False, non-grouping
2780+ columns will appear in the order they occur in within groups.
27812781
27822782 .. versionchanged:: 3.0.0
27832783
You can’t perform that action at this time.
0 commit comments