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: Add fillna at the beginning of _where not to fill NA. #60729 #60772

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

Conversation

sanggon6107
Copy link

Added fillna at the beginning of _where so that we can fill pd.NA.
Since this is my first PR, please correct me if I'm mistaken. Thanks!


def test_mask_na():
# We should not be filling pd.NA. See GH#60729
series = Series([None, 1, 2, None, 3, 4, None])
Copy link
Member

Choose a reason for hiding this comment

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

I think this test can be simplified a bit to reduce the number of operations. Maybe something like:

ser = Series([None, 1, 2, None, 3, 4, None], dtype=pd.Int64Dtype())
result = ser.mask(ser <= 2, -99)
expected = Series([None, 1, 2, None, -99, -99, None], dtype=pd.Int64Dtype())

tm.assert_series_equal(result, expected)

@@ -9674,6 +9674,13 @@ def _where(
if axis is not None:
axis = self._get_axis_number(axis)

# We should not be filling NA. See GH#60729
Copy link
Member

Choose a reason for hiding this comment

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

Is this trying to fill missing values when NaN is the missing value indicator? I don't think that is right either - the missing values should propogate for all types. We may just be missing coverage for the NaN case (which should be added to the test)

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

Successfully merging this pull request may close these issues.

BUG: Series.mask incorrectly replaces positions of pd.NA in the cond argument
2 participants