Skip to content

Commit faf22ed

Browse files
committed
compat for old numpy
1 parent ea7b1d3 commit faf22ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/core/array_algos/putmask.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ def putmask_without_repeat(
8181
# TODO: this prob needs some better checking for 2D cases
8282
nlocs = mask.sum()
8383
if nlocs > 0 and is_list_like(new) and getattr(new, "ndim", 1) == 1:
84-
if nlocs == len(new):
84+
shape = np.shape(new)
85+
# np.shape compat for if setitem_datetimelike_compat
86+
# changed arraylike to list e.g. test_where_dt64_2d
87+
88+
if nlocs == shape[-1]:
8589
# GH#30567
8690
# If length of ``new`` is less than the length of ``values``,
8791
# `np.putmask` would first repeat the ``new`` array and then
@@ -90,7 +94,7 @@ def putmask_without_repeat(
9094
# to place in the masked locations of ``values``
9195
np.place(values, mask, new)
9296
# i.e. values[mask] = new
93-
elif mask.shape[-1] == len(new) or len(new) == 1:
97+
elif mask.shape[-1] == shape[-1] or shape[-1] == 1:
9498
np.putmask(values, mask, new)
9599
else:
96100
raise ValueError("cannot assign mismatch length to masked array")

0 commit comments

Comments
 (0)