-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Closed
Labels
BugDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull requestNA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arrays
Description
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
Metadata
Metadata
Assignees
Labels
BugDuplicate ReportDuplicate issue or pull requestDuplicate issue or pull requestNA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arrays