Skip to content

Commit f83ce4d

Browse files
authored
DOC: Add list of UDF methods to mutation gotcha (#39851)
1 parent 3f39757 commit f83ce4d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/source/user_guide/gotchas.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ testing for membership in the list of column names.
183183
Mutating with User Defined Function (UDF) methods
184184
-------------------------------------------------
185185

186+
This section applies to pandas methods that take a UDF. In particular, the methods
187+
``.apply``, ``.aggregate``, ``.transform``, and ``.filter``.
188+
186189
It is a general rule in programming that one should not mutate a container
187190
while it is being iterated over. Mutation will invalidate the iterator,
188191
causing unexpected behavior. Consider the example:
@@ -246,7 +249,6 @@ not apply to the container being iterated over.
246249
df = pd.DataFrame({"a": [1, 2, 3], 'b': [4, 5, 6]})
247250
df.apply(f, axis="columns")
248251
249-
250252
``NaN``, Integer ``NA`` values and ``NA`` type promotions
251253
---------------------------------------------------------
252254

0 commit comments

Comments
 (0)