Skip to content

Commit 13f28f5

Browse files
jrebackjorisvandenbossche
authored andcommitted
COMPAT: numpy compat with 1-ndim object array compat and broadcasting (#14809)
xref #14808 (cherry picked from commit 0412732)
1 parent 11eb8ab commit 13f28f5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/core/ops.py

+7
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,13 @@ def na_op(x, y):
11761176
yrav = y.ravel()
11771177
mask = notnull(xrav) & notnull(yrav)
11781178
xrav = xrav[mask]
1179+
1180+
# we may need to manually
1181+
# broadcast a 1 element array
1182+
if yrav.shape != mask.shape:
1183+
yrav = np.empty(mask.shape, dtype=yrav.dtype)
1184+
yrav.fill(yrav.item())
1185+
11791186
yrav = yrav[mask]
11801187
if np.prod(xrav.shape) and np.prod(yrav.shape):
11811188
with np.errstate(all='ignore'):

0 commit comments

Comments
 (0)