Skip to content

Doc: Add warning to treat group chunks as immutable #19175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/source/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -941,11 +941,15 @@ that is itself a series, and possibly upcast the result to a DataFrame:

.. warning::

In the current implementation apply calls func twice on the
* In the current implementation ``apply`` calls func twice on the
first group to decide whether it can take a fast or slow code
path. This can lead to unexpected behavior if func has
side-effects, as they will take effect twice for the first
group.

* For predictable results and performance, func should **not** mutate
any of the group chunks. Group chunks should be treated as immutable
since changes to a group chunk may produce unexpected results.

.. ipython:: python

Expand Down