Skip to content

Commit b439dfc

Browse files
bashtageKevin Sheppard
authored and
Kevin Sheppard
committed
MAINT: Fix broadcasting of arrays
Prevent empty object arrays from being broadcast
1 parent a0c8425 commit b439dfc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/core/internals/construction.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,11 @@ def init_dict(data: Dict, index, columns, dtype: Optional[DtypeObj] = None):
266266
else:
267267
nan_dtype = dtype
268268
val = construct_1d_arraylike_from_scalar(np.nan, len(index), nan_dtype)
269-
arrays.loc[missing] = [val] * missing.sum()
270-
269+
if val.size == 0:
270+
for iloc in np.where(missing)[0]:
271+
arrays.iloc[iloc] = val
272+
else:
273+
arrays.loc[missing] = [val] * missing.sum()
271274
else:
272275
keys = list(data.keys())
273276
columns = data_names = Index(keys)

0 commit comments

Comments
 (0)