Skip to content

Commit a88a756

Browse files
jbrockmendelluckyvs1
authored andcommitted
BUG: algos.rank with readonly values (pandas-dev#38396)
1 parent 2c1949e commit a88a756

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

pandas/_libs/algos.pyx

+1-6
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ def rank_1d(
824824
if values.dtype != np.object_:
825825
values = values.astype('O')
826826
else:
827-
values = np.asarray(in_arr)
827+
values = np.asarray(in_arr).copy()
828828

829829
keep_na = na_option == 'keep'
830830

@@ -835,11 +835,6 @@ def rank_1d(
835835
elif rank_t is int64_t:
836836
mask = values == NPY_NAT
837837

838-
# create copy in case of NPY_NAT
839-
# values are mutated inplace
840-
if mask.any():
841-
values = values.copy()
842-
843838
# double sort first by mask and then by values to ensure nan values are
844839
# either at the beginning or the end. mask/(~mask) controls padding at
845840
# tail or the head

pandas/tests/util/test_show_versions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def test_show_versions(capsys):
3939
assert re.search(r"commit\s*:\s[0-9a-f]{40}\n", result)
4040

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

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

0 commit comments

Comments
 (0)