-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Fixed type hints for GroupBy.{any, all} #36284
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
DOC: Fixed type hints for GroupBy.{any, all} #36284
Conversation
The current documentation says the return value of GroupBy.all and GroupBy.any is `bool`. ``` def any(self, skipna: bool = True): """ Return True if any value in the group is truthful, else False. Parameters ---------- skipna : bool, default True Flag to ignore nan values during truth testing. Returns ------- bool """ ``` However, the actual returned type is DataFrame or Series (the same shape as `GroupBy.sum()`). ``` In [25]: df Out[25]: 0 1 2 3 0 1.0 0.0 0.0 0.0 1 0.0 1.0 0.0 0.0 2 0.0 0.0 1.0 0.0 3 0.0 0.0 0.0 1.0 In [26]: df.groupby(0).any() Out[26]: 1 2 3 0 0.0 True True True 1.0 False False False In [27]: type(df.groupby(0).any()) Out[27]: pandas.core.frame.DataFrame ``` This PR fixes the wrong type hints for `GroupBy.{any, all}`.
That is a bit short imho. Could you maybe write something like here ? https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.sum.html |
Okay. I wrote some drafts for
If you have any alternative, plz tell me. |
Hello @ytakashina! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-10-09 00:30:11 UTC |
Edited the description for the return value of GroupBy.{any, all} after receiving @rhshadrach's suggestion. |
Seems like a clear improvement over the status quo. @rhshadrach are you happy here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - thanks @ytakashina
@ytakashina Can you merge master? I think it will fix CI. |
…type-hinting-groupby
…type-hinting-groupby
…type-hinting-groupby
@rhshadrach CI Fixed! |
Thanks @ytakashina! |
The current documentation says the return value of GroupBy.all and GroupBy.any is
bool
.However, the actual returned type is DataFrame or Series (with the same shape as
GroupBy.sum()
).This PR fixes the wrong type hints for
GroupBy.{any, all}
.black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff