API: Should isna return a copy for nullable types? · Issue #40935 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@mzeitlin11

Description

@mzeitlin11

This came up in #40651, seems worth resolving. Right now BaseMaskedArray just directly returns self._mask in the implementation of isna. This could lead to some unintuitive user-facing behavior like:

>>> ser = pd.Series([1, 1, 1], dtype="Int64")
>>> mask = ser.isna()
>>> mask[:] = True
>>> ser
0    <NA>
1    <NA>
2    <NA>
dtype: Int64

Seems like isna should return a copy instead to avoid this. One potential downside is losing an API-supported way to obtain 0-cost access to the mask (xref #34873).