diff --git a/doc/source/user_guide/groupby.rst b/doc/source/user_guide/groupby.rst index f74012cf51d4a..88727bc8f9025 100644 --- a/doc/source/user_guide/groupby.rst +++ b/doc/source/user_guide/groupby.rst @@ -196,7 +196,7 @@ only verifies that you've passed a valid mapping. GroupBy sorting ~~~~~~~~~~~~~~~~~~~~~~~~~ -By default the group keys are sorted during the ``groupby`` operation. You may however pass ``sort=False`` for potential speedups: +By default the group keys are sorted during the ``groupby`` operation. You may however pass ``sort=False`` for potential speedups. With ``sort=False`` the order among group-keys follows the order of appearance of the keys in the original dataframe: .. ipython:: python diff --git a/pandas/core/shared_docs.py b/pandas/core/shared_docs.py index 8344430ca5bb9..0e37ec5dc45f0 100644 --- a/pandas/core/shared_docs.py +++ b/pandas/core/shared_docs.py @@ -130,7 +130,8 @@ sort : bool, default True Sort group keys. Get better performance by turning this off. Note this does not influence the order of observations within each - group. Groupby preserves the order of rows within each group. + group. Groupby preserves the order of rows within each group. If False, + the groups will appear in the same order as they did in the original DataFrame. This argument has no effect on filtrations (see the `filtrations in the user guide `_), such as ``head()``, ``tail()``, ``nth()`` and in transformations