Skip to content

DOC: GH5456 Adding workaround info on NA / NaT handling for groupby #47337

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
5 changes: 5 additions & 0 deletions doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,11 @@ automatically excluded. In other words, there will never be an "NA group" or
generally discarding the NA group anyway (and supporting it was an
implementation headache).

.. note::
If you need to include NaN or NaT values in your grouping, you can workaround the automatic exclusion by replacing
the NaN / NaT values with a placeholder string. For example, you can use ``df.fillna("default", inplace=True)`` to
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

  1. Could you demonstrate this by including a .. ipython:: python example (like above)
  2. In the example, could you exclude inplace=True? We are trying to discourage that keyword generally

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do on both!

Do you think it makes sense to pull it out of a note and just include it in line with the rest of the text if we're including an ipython?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah sure that sounds reasonable

create a **default** group in your dataframe that captures NaN / NaT values.

Grouping with ordered factors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down