Skip to content

Commit d438e8b

Browse files
author
Shashwat1001
committed
Made the changes
1 parent f10c147 commit d438e8b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

doc/source/user_guide/basics.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,12 @@ either match on the *index* or *columns* via the **axis** keyword:
209209
df.sub(column, axis="index")
210210
df.sub(column, axis=0)
211211
212-
Be careful when using raw Python lists in binary operations with DataFrames.
213-
Unlike NumPy arrays or Series, lists are not broadcast across rows or columns.
214-
Instead, pandas attempts to match the entire list against a single axis, which may lead to confusing results such as Series of arrays.
215-
To ensure proper broadcasting behavior, use a NumPy array or Series with explicit index or shape.
216-
Furthermore you can align a level of a MultiIndexed DataFrame with a Series.
212+
Use .add(array, axis=0) to broadcast values row-wise, ensuring each element in the array is
213+
applied to the corresponding row. This avoids accidental column alignment and preserves expected element-wise behavior.
214+
215+
.. ipython:: python
216+
217+
df.add(np.array([1, 2, 3]), axis=0)
217218
218219
.. ipython:: python
219220

0 commit comments

Comments
 (0)