Skip to content

Contribute to issue #15580 #28264

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
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: 3 additions & 3 deletions doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ By default the group keys are sorted during the ``groupby`` operation. You may h

.. ipython:: python

df2 = pd.DataFrame({'X': ['B', 'B', 'A', 'A'], 'Y': [1, 2, 3, 4]})
df2 = pd.DataFrame({'X': ['A', 'A', 'B', 'B'], 'Y': [1, 2, 3, 4]})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was deliberate. We want the X column to be unsorted so that the two operations below (sort=True/False) are differentiations.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now reading it more carefully I can see the intention of this section. I will pay more attention when proposing small changes similar to that one, sorry.

df2.groupby(['X']).sum()
df2.groupby(['X'], sort=False).sum()

Expand Down Expand Up @@ -703,7 +703,7 @@ code would work even without the special versions via dispatching (see below).
Transformation
--------------

The ``transform`` method returns an object that is indexed the same (same size)
The ``transform`` method returns an object that is indexed with the same size
as the one being grouped. The transform function must:

* Return a result that is either the same size as the group chunk or
Expand Down Expand Up @@ -799,7 +799,7 @@ Another common data transform is to replace missing data with the group mean.
transformed = grouped.transform(lambda x: x.fillna(x.mean()))

We can verify that the group means have not changed in the transformed data
and that the transformed data contains no NAs.
and that the transformed data contains no NAN's.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to use NA to refer to missing values in generally. We'll sometimes use np.nan when talking about that specific specific missing value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, got it!


.. ipython:: python

Expand Down