-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
BUG: rank_2d raising with mixed dtypes #38932
Conversation
try: | ||
_as = values.argsort(1) | ||
except TypeError: | ||
values = in_arr |
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.
This is the source of the bug - if axis=0
, values is supposed to be transposed (as done earlier in the function) - setting equal to in_arr
makes values
the wrong shape since in_arr
was not transposed
pct=pct | ||
) | ||
if axis == 0: | ||
return ranks.T |
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.
This whole try/except is not necessary because the except clause will always raise a TypeError
anyway since if values.argsort(1)
raises a TypeError
, at least one column in values
must not be sortable, so that same column will cause another TypeError
to be raised when trying to fallback to rank_1d
doc/source/whatsnew/v1.3.0.rst
Outdated
@@ -217,6 +217,8 @@ Numeric | |||
- Bug in :meth:`DataFrame.select_dtypes` with ``include=np.number`` now retains numeric ``ExtensionDtype`` columns (:issue:`35340`) | |||
- Bug in :meth:`DataFrame.mode` and :meth:`Series.mode` not keeping consistent integer :class:`Index` for empty input (:issue:`33321`) | |||
- Bug in :meth:`DataFrame.rank` with ``np.inf`` and mixture of ``np.nan`` and ``np.inf`` (:issue:`32593`) | |||
- Bug in :meth:`DataFrame.rank` with ``axis=0`` and columns holding incomparable types raising ``IndexError`` |
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.
if there is not issue (its fine don't create one), but add this PR number as the issue number.
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.
Thanks for committing that, yep no issue
thanks @mzeitlin11 keep em coming! |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff