Skip to content

Commit f10c147

Browse files
author
Shashwat1001
committed
Changes as per comment
1 parent 0e718bc commit f10c147

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/source/user_guide/dsintro.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,12 +650,12 @@ row-wise. For example:
650650
651651
df - df.iloc[0]
652652
653-
When using a Python list in arithmetic operations with a DataFrame, the behavior is not element-wise broadcasting.
654-
Instead, the list is treated as a single object and the operation is performed column-wise, resulting in unexpected output (e.g. arrays inside each cell).
653+
Use .add(array, axis=0) to apply row-wise broadcasting when the array length matches the number of rows —
654+
this ensures element-wise operations are performed across each row, rather than mistakenly aligning with columns.
655655

656656
.. ipython:: python
657657
658-
df + np.array([1, 2, 3])
658+
df.add(np.array([1, 2, 3]), axis=0)
659659
660660
For explicit control over the matching and broadcasting behavior, see the
661661
section on :ref:`flexible binary operations <basics.binop>`.

0 commit comments

Comments
 (0)