Skip to content

Commit 9961b14

Browse files
committed
re-allow dict
1 parent 3ba34f5 commit 9961b14

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/core/arraylike.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ def __add__(self, other):
142142
elk 2.0 501.5
143143
moose 3.1 801.5
144144
145+
Keys of a dictionary are aligned to the DataFrame, based on column names;
146+
each value in the dictionary is added to the corresponding column.
147+
148+
>>> df[["height", "weight"]] + {"height": 0.5, "weight": 1.5}
149+
height weight
150+
elk 2.0 501.5
151+
moose 3.1 801.5
152+
145153
When `other` is a :class:`Series`, the index of `other` is aligned with the
146154
columns of the DataFrame.
147155

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8430,7 +8430,7 @@ def to_series(right):
84308430
)
84318431

84328432
elif is_list_like(right) and not isinstance(right, (Series, DataFrame)):
8433-
if not isinstance(right, (np.ndarray, ExtensionArray, Index, list)):
8433+
if not isinstance(right, (np.ndarray, ExtensionArray, Index, list, dict)):
84348434
warnings.warn(
84358435
f"Operation with {type(right).__name__} are deprecated. "
84368436
"In a future version these will be treated as scalar-like. "

0 commit comments

Comments
 (0)