-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
ENH: Modify .any() to return Null if all values are null #41967
Comments
Thanks for the request @rapatel0! Does https://pandas.pydata.org/pandas-docs/stable/user_guide/boolean.html satisfy what you are looking for? For the new
I think there are still some inconsistencies with this behavior, though, for example
should be |
Running a simple groupby in front of the series code implies that some masking logic is failing or probably type promotion.
|
When you ran (EDIT: what I said above is only valid for version 1.3, before that there were other issues) |
Closing for now, but please ping to reopen if you think there's any other weird behavior here @rapatel0 |
Is your feature request related to a problem?
For sparce data it is particuarly helpful to preserve null values when doing reduction operations. I end up using this (see below) wrapper function to achieve the intended result.
Describe the solution you'd like
The ask is to add a configuration parameter to.
.any()
and.all()
that optionally preserves null values when returning the array. Skipna doesn't seem to have to correct functionality as it will return false, if all the values of the array are null. Ideally, with the toggleable parameter,.any()
would returnnp.nan/pd.NA
if all values in the array are null.API breaking implications
This shouldn't change the api. It will just add an optional parameter
Describe alternatives you've considered
pd.NA
The text was updated successfully, but these errors were encountered: