Skip to content

Backport PR #38396 on branch 1.2.x (BUG: algos.rank with readonly values) #38409

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def rank_1d(
if values.dtype != np.object_:
values = values.astype('O')
else:
values = np.asarray(in_arr)
values = np.asarray(in_arr).copy()

keep_na = na_option == 'keep'

Expand All @@ -835,11 +835,6 @@ def rank_1d(
elif rank_t is int64_t:
mask = values == NPY_NAT

# create copy in case of NPY_NAT
# values are mutated inplace
if mask.any():
values = values.copy()

# double sort first by mask and then by values to ensure nan values are
# either at the beginning or the end. mask/(~mask) controls padding at
# tail or the head
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/util/test_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def test_show_versions(capsys):
assert re.search(r"commit\s*:\s[0-9a-f]{40}\n", result)

# check required dependency
assert re.search(r"numpy\s*:\s([0-9\.\+a-f\_]|dev)+\n", result)
# 2020-12-09 npdev has "dirty" in the tag
assert re.search(r"numpy\s*:\s([0-9\.\+a-g\_]|dev)+(dirty)?\n", result)

# check optional dependency
assert re.search(r"pyarrow\s*:\s([0-9\.]+|None)\n", result)