Skip to content

Commit 9421192

Browse files
committed
moar fixes
1 parent f47d6f5 commit 9421192

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/core/internals.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,23 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0,
855855
new, new_values.shape[-1]).reshape(self.shape)
856856
new = new.astype(new_values.dtype)
857857

858+
# we require exact matches between the len of the
859+
# values we are setting (or is compat). np.putmask
860+
# doesn't check this and will simply truncate / pad
861+
# the output, but we want sane error messages
862+
#
863+
# TODO: this prob needs some better checking
864+
# for 2D cases
865+
if ((is_list_like(new) and
866+
np.any(mask[mask]) and
867+
getattr(new, 'ndim', 1) == 1)):
868+
869+
if not (mask.shape[-1] == len(new) or
870+
mask[mask].shape[-1] == len(new) or
871+
len(new) == 1):
872+
raise ValueError("cannot assign mismatch "
873+
"length to masked array")
874+
858875
np.putmask(new_values, mask, new)
859876

860877
# maybe upcast me

0 commit comments

Comments
 (0)