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: Bug in mask method when handling pd.NA with Int64Dtype #60794

Closed
2 of 3 tasks
IceyDuan opened this issue Jan 26, 2025 · 2 comments
Closed
2 of 3 tasks

BUG: Bug in mask method when handling pd.NA with Int64Dtype #60794

IceyDuan opened this issue Jan 26, 2025 · 2 comments
Labels
Bug Duplicate Report Duplicate issue or pull request NA - MaskedArrays Related to pd.NA and nullable extension arrays

Comments

@IceyDuan
Copy link

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
from pandas import Series
from pandas.api.extensions import Int64Dtype
series = Series([None, 1, 2, None, 3, 4, None], dtype=Int64Dtype())
result = series.mask(series <= 2, -99)
print(result)

Issue Description

I am encountering an issue with the mask method in pandas when it is used with a Series of type Int64Dtype. Specifically, when trying to mask pd.NA values, they are being replaced, which is not the expected behavior. I expected the pd.NA values to remain unchanged, but they are being incorrectly filled.

Expected Behavior

Series([None, -99, -99, None, 3, 4, None], dtype=Int64Dtype())

Installed Versions

python: 3.11.1
pandas: 2.1.3

@IceyDuan IceyDuan added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 26, 2025
@asishm
Copy link
Contributor

asishm commented Jan 26, 2025

Thanks for the report. This is a duplicate of #60729

@rhshadrach
Copy link
Member

Agreed @asishm - closing.

@rhshadrach rhshadrach added Duplicate Report Duplicate issue or pull request NA - MaskedArrays Related to pd.NA and nullable extension arrays and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

No branches or pull requests

3 participants