Skip to content

Commit b13a3cf

Browse files
committed
Fix Dataframe.apply documentation to include note regarding calling function twice on first element
1 parent 8aa7072 commit b13a3cf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/core/frame.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7204,6 +7204,14 @@ def apply(self, func, axis=0, raw=False, result_type=None, args=(), **kwds):
72047204
DataFrame.aggregate: Only perform aggregating type operations.
72057205
DataFrame.transform: Only perform transforming type operations.
72067206
7207+
Notes
7208+
-----
7209+
In the current implementation apply calls `func` twice on the
7210+
first column/row to decide whether it can take a fast or slow
7211+
code path. This can lead to unexpected behavior if `func` has
7212+
side-effects, as they will take effect twice for the first
7213+
column/row.
7214+
72077215
Examples
72087216
--------
72097217
>>> df = pd.DataFrame([[4, 9]] * 3, columns=['A', 'B'])

0 commit comments

Comments
 (0)