Skip to content

DOC: sort has no effect on filters #51825

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

Merged
merged 7 commits into from
Mar 10, 2023

Conversation

natmokval
Copy link
Contributor

Updated docs for DataFrame.groupby and Series.groupby, pointed out that the parameter the sort parameter has no effect on filters.

@natmokval natmokval closed this Mar 7, 2023
@natmokval natmokval reopened this Mar 7, 2023
@mroeschke mroeschke added the Docs label Mar 7, 2023
@natmokval natmokval marked this pull request as ready for review March 8, 2023 16:15
@natmokval
Copy link
Contributor Author

In the API docs for DataFrame.groupby and Series.groupby the fact that as_index has no effect on filters is not mentioned.
Should I mention it?

Comment on lines 122 to 123
This argument has no effect on some aggregating functions, such as
:ref:`head, tail <basics.aggregate>` and ``nth[:]``.
Copy link
Member

Choose a reason for hiding this comment

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

it might be good to mention "filtrations" rather than "some aggregating functions", and link to the "filtrations" section introduced in https://github.com/pandas-dev/pandas/pull/51704/files?

as yes, it might be good to note it in as_index too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I did as you suggested. I think ci failures aren't related to my changes.

Copy link
Member

Choose a reason for hiding this comment

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

thanks!

not sure, it's showing

/home/runner/work/pandas/pandas/pandas/core/frame.py:docstring of pandas.core.frame.DataFrame.groupby:210: WARNING: Duplicate explicit target name: "groupby user guide".
/home/runner/work/pandas/pandas/pandas/core/frame.py:docstring of pandas.core.frame.DataFrame.groupby:210: WARNING: Duplicate explicit target name: "groupby user guide".
/home/runner/work/pandas/pandas/pandas/core/series.py:docstring of pandas.core.series.Series.groupby:188: WARNING: Duplicate explicit target name: "groupby user guide".
/home/runner/work/pandas/pandas/pandas/core/series.py:docstring of pandas.core.series.Series.groupby:188: WARNING: Duplicate explicit target name: "groupby user guide".

which might be due to the link you wrote?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the comment. I agree, the warnings are related to my changes. There are two different links in one doctsring with the same name, which causes the problem. I changed the name of my link.

It’s interesting, while I run validation
python scripts/validate_docstrings.py pandas.core.groupby.DataFrameGroupBy and
python scripts/validate_docstrings.py pandas.core.groupby.SeriesGroupBy there were no warnings.

After validation, I cleaned and built new documentation locally. Then I just checked html, my links worked right. My mistake, I should check warnings raised by the build.

@MarcoGorelli MarcoGorelli requested a review from rhshadrach March 9, 2023 10:29
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@@ -114,11 +114,17 @@
as_index : bool, default True
For aggregated output, return object with group labels as the
Copy link
Member

Choose a reason for hiding this comment

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

With your addition (if we add in transformations, see below), I think "For aggregated output," can be removed. But I'm also okay with it staying as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed "For aggregated output,". With my addition, there is no need to write this.

Comment on lines 117 to 120
effectively "SQL-style" grouped output. This argument has no effect
on filtrations (see the `filtration user guide
<https://pandas.pydata.org/docs/dev/user_guide/groupby.html#filtration>`_),
such as ``head()``, ``tail()`` and ``nth()``.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add in transformations here as well?

I would describe it as "filtrations in the user guide" rather than "filteration user guide"; what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, "filtrations in the user guide" sounds more correct and more clear.

Comment on lines 125 to 127
This argument has no effect on filtrations (see the `filtration user guide
<https://pandas.pydata.org/docs/dev/user_guide/groupby.html#filtration>`_),
such as ``head()``, ``tail()`` and ``nth()``.
Copy link
Member

Choose a reason for hiding this comment

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

Similar remarks here.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

Changes look good, just waiting on the docs build to double check the output.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

lgtm

@rhshadrach
Copy link
Member

@MarcoGorelli - any further comments?

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Nice, thanks @natmokval and @rhshadrach !

shipping it then

@MarcoGorelli MarcoGorelli added this to the 2.1 milestone Mar 10, 2023
@MarcoGorelli MarcoGorelli merged commit c293caf into pandas-dev:main Mar 10, 2023
@natmokval
Copy link
Contributor Author

Thanks @MarcoGorelli and @rhshadrach for helping me with this pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

groupby weird behavior
4 participants