8000 MAINT: Fix broadcasting of arrays by bashtage · Pull Request #35485 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Fix broadcasting of arrays #35485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
MAINT: Fix broadcasting of arrays
Prevent empty object arrays from being broadcast
  • Loading branch information
bashtage authored and Kevin Sheppard committed Aug 2, 2020
commit b439dfc88f66eb64a0529d5030b026ac6e6cbd7c
7 changes: 5 additions & 2 deletions pandas/core/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,11 @@ def init_dict(data: Dict, index, columns, dtype: Optional[DtypeObj] = None):
else:
nan_dtype = dtype
val = construct_1d_arraylike_from_scalar(np.nan, len(index), nan_dtype)
arrays.loc[missing] = [val] * missing.sum()

if val.size == 0:
for iloc in np.where(missing)[0]:
arrays.iloc[iloc] = val
else:
arrays.loc[missing] = [val] * missing.sum()
else:
keys = list(data.keys())
columns = data_names = Index(keys)
Expand Down
0