-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: groupby any/all raising with pd.NA object data #42085
Conversation
mzeitlin11
commented
Jun 17, 2021
- closes BUG: Groupby any/all raises TypeError for pd.NA #37501
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
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.
cc @rhshadrach if you can look
doc/source/whatsnew/v1.4.0.rst
Outdated
@@ -187,7 +187,7 @@ Plotting | |||
|
|||
Groupby/resample/rolling | |||
^^^^^^^^^^^^^^^^^^^^^^^^ | |||
- | |||
- :meth:`.GroupBy.any` and :meth:`.GroupBy.all` raising with ``object`` data containing ``pd.NA`` even when ``skipna=True`` (:issue:`37501`) |
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.
ok to move to 1.3
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.
have moved
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 good - minor request below.
pandas/core/groupby/groupby.py
Outdated
# GH#37501: don't raise on pd.NA when skipna=True | ||
vals = np.array( | ||
[bool(x) if not (skipna and isna(x)) else True for x in vals] | ||
) |
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.
While slightly more verbose, it seems better to me to avoid evaluating skipna
at each iteration:
if skipna:
vals = np.array(
[bool(x) if not isna(x) else True for x in vals]
)
else:
vals = np.array([bool(x) for x in vals])
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.
Sounds good, have changed
thanks @mzeitlin11 |
@meeseeksdev backport 1.3.x |
Something went wrong ... Please have a look at my logs. |
…ta (#42164) Co-authored-by: Matthew Zeitlin <37011898+mzeitlin11@users.noreply.github.com>