Skip to content
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: fix #59965 skipna=True operations don't skip NaN in FloatingArrays #59997

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

cooolheater
Copy link

@cooolheater cooolheater commented Oct 7, 2024

- Issue: The skipna was not properly handled for BaseMaskedArray
- Fix: Added mask for NA values
- Test: Added test to series/test_reductions since the test uses

…oatingArrays

    - Issue: The skipna was not properly handled for BaseMaskedArray
    - Fix: Added mask for NA values
    - Test: Added test to series/test_reductions since the test uses
@cooolheater cooolheater marked this pull request as draft October 9, 2024 05:18
@cooolheater cooolheater marked this pull request as ready for review October 9, 2024 05:19
@cooolheater cooolheater force-pushed the cooolheater-issue59965 branch from c73603f to cc63891 Compare October 14, 2024 11:45
pandas/core/array_algos/masked_reductions.py Outdated Show resolved Hide resolved
pandas/tests/series/test_reductions.py Outdated Show resolved Hide resolved
pandas/tests/series/test_reductions.py Outdated Show resolved Hide resolved
@cooolheater cooolheater force-pushed the cooolheater-issue59965 branch from 581665a to edc977e Compare October 23, 2024 14:31
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.

I think this looks good! Also will need a whatsnew note in the Numeric section of v3.0.0.rst.

series1 = Series({"a": 0.0, "b": 1, "c": 1}, dtype="Float64")
series2 = Series({"a": 0.0, "b": 2, "c": 2}, dtype="Float64")
result = series1 / series2
assert pd.notna(result.mean(skipna=True))
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can you assert the value here (it is a slightly stronger test). Can use np.isclose.

@mroeschke mroeschke added Reduction Operations sum, mean, min, max, etc. Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Oct 30, 2024
@rhshadrach
Copy link
Member

Apologies @cooolheater - based on the discussion in the linked issue, I think we have to hold off making changes here until a consensus is reached on how to handle various NA values across pandas. There is already a PDEP in progress for this, but it will likely be quite some time until we're ready for this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate NA - MaskedArrays Related to pd.NA and nullable extension arrays Reduction Operations sum, mean, min, max, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: skipna=True operations don't skip NaN in FloatingArrays
3 participants