-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
CLN: Refactor some sorting code in Index set operations #24533
Conversation
with tm.assert_produces_warning(warning_type): | ||
# Python 3: Unorderable types | ||
s3 = s1 * s2 | ||
s3 = s1 * s2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a couple of places where the above warning was given. But now that the safe_sort
function is used the warning is no longer given because safe_sort
tries to sort some "unorderable" types:
Lines 448 to 466 in 091cfbb
def sort_mixed(values): | |
# order ints before strings, safe in py3 | |
str_pos = np.array([isinstance(x, string_types) for x in values], | |
dtype=bool) | |
nums = np.sort(values[~str_pos]) | |
strs = np.sort(values[str_pos]) | |
return np.concatenate([nums, np.asarray(strs, dtype=object)]) | |
sorter = None | |
if PY3 and lib.infer_dtype(values) == 'mixed-integer': | |
# unorderable in py3 if mixed str/int | |
ordered = sort_mixed(values) | |
else: | |
try: | |
sorter = values.argsort() | |
ordered = values.take(sorter) | |
except TypeError: | |
# try this anyway | |
ordered = sort_mixed(values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, this is the intent of the function
Codecov Report
@@ Coverage Diff @@
## master #24533 +/- ##
=======================================
Coverage 31.88% 31.88%
=======================================
Files 166 166
Lines 52427 52427
=======================================
Hits 16714 16714
Misses 35713 35713
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #24533 +/- ##
=======================================
Coverage 31.88% 31.88%
=======================================
Files 166 166
Lines 52427 52427
=======================================
Hits 16714 16714
Misses 35713 35713
Continue to review full report at Codecov.
|
thanks @reidy-p |
* upstream/master: Make DTI[tz]._values and Series[tz]._values return DTA (pandas-dev#24534) CLN: Refactor some sorting code in Index set operations (pandas-dev#24533) Run isort (pandas-dev#24530) CI: fix db usage in CI (pandas-dev#24529)
git diff upstream/master -u -- "*.py" | flake8 --diff
This is a pre-cursor to #24521 and cleans up some of the sorting code in set operations on
Index
.