From b98e0ce2ac5984a8b19517fdbe81cb65b35f2a8f Mon Sep 17 00:00:00 2001 From: Patrick Park Date: Tue, 16 Oct 2018 08:15:32 -0700 Subject: [PATCH] Doc: Add warning to treat group chunks as immutable Resolves: #14180 --- doc/source/groupby.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/source/groupby.rst b/doc/source/groupby.rst index fecc336049a40..188ca80fbcd11 100644 --- a/doc/source/groupby.rst +++ b/doc/source/groupby.rst @@ -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