-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: stabilize sort_values algorithms for Series and time-like Indices #37310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
151c425
7332255
546b9fa
12eb535
9b51d42
7805d1e
2b75f78
2844a97
965a547
29d47ee
151196d
d71bfc8
aff28ac
0b8aae9
e7cebc4
06931e0
0b24c3e
1b98bff
4076f0c
08aadd3
6f904e6
5c7eea9
75aad12
e503dca
759de34
12741f2
d433952
dc906df
dbf295e
cbe528e
6658b73
076fa7a
cdf63a3
dd30ec9
5cac5c7
7a68a45
4c72dbf
3599591
3ee9b8b
d63293c
a5c8f65
fc90ea9
408abe0
5f53cfc
4370f27
6099344
bfa2b28
bc004ec
cd7111e
5fbbf7d
95b9f25
1dc9b89
2946e46
488596c
c8cd8cd
ab71697
05f60d5
8669e89
00b454c
5d5f3d0
3d7f47c
351a003
8de6ac9
18bb141
9b97302
3a88ebe
d41789e
812f312
e28ce4d
0719633
61ac60d
d495064
36932cd
2156c64
e6f5741
c823043
cd66748
37a6439
d09da99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4510,9 +4510,7 @@ def sort_values( | |
|
||
# GH 35584. Sort missing values according to na_position kwarg | ||
# ignore na_position for MultiIndex | ||
if not isinstance( | ||
self, (ABCMultiIndex, ABCDatetimeIndex, ABCTimedeltaIndex, ABCPeriodIndex) | ||
): | ||
if not isinstance(self, ABCMultiIndex): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Support everything except |
||
_as = nargsort( | ||
items=idx, ascending=ascending, na_position=na_position, key=key | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -374,7 +374,16 @@ def nargsort( | |
if not ascending: | ||
non_nans = non_nans[::-1] | ||
non_nan_idx = non_nan_idx[::-1] | ||
indexer = non_nan_idx[non_nans.argsort(kind=kind)] | ||
|
||
# GH 35922. Move support for object sort here from Series.sort_values | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment is not super useful, what is an expl of why you need this try/except e.g. L380 move here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer relevant, since I removed the try/except. |
||
try: | ||
# if kind==mergesort, it can fail for object dtype | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why can this fail? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback I moved this code from |
||
indexer = non_nan_idx[non_nans.argsort(kind=kind)] | ||
except TypeError: | ||
# stable sort not available for object dtype | ||
# uses the argsort default quicksort | ||
indexer = non_nan_idx[non_nans.argsort(kind="quicksort")] | ||
|
||
if not ascending: | ||
indexer = indexer[::-1] | ||
# Finally, place the NaNs at the end or the beginning according to | ||
|
Uh oh!
There was an error while loading. Please reload this page.