Skip to content

BUG: Mask changing value despite of no True return #61505

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

Closed
3 tasks done
frbelotto opened this issue May 27, 2025 · 1 comment
Closed
3 tasks done

BUG: Mask changing value despite of no True return #61505

frbelotto opened this issue May 27, 2025 · 1 comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@frbelotto
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

data = {'cd_tip_fma_pgto': [pd.NA]}
df = pd.DataFrame(data, dtype='double[pyarrow]')
df['payment'] = np.nan
df['payment'] = df['payment'].mask(cond=(df['cd_tip_fma_pgto'] == 6), other='Livelo')

Issue Description

Evaluating the mask method under a pd.NA, when using pyarrow, is changing the target value!

Image

Expected Behavior

The results of the compasison should not cause any change of the target value, as you see in this example :

data = {'cd_tip_fma_pgto': [pd.NA]}
df = pd.DataFrame(data)
df['payment'] = np.nan
df['payment'] = df['payment'].mask(cond=(df['cd_tip_fma_pgto'] == 6), other='Livelo')

Image

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.11.0
python-bits : 64
OS : Linux
OS-release : 3.10.0-1127.19.1.el7.x86_64
Version : #1 SMP Tue Aug 25 17:23:54 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8

pandas : 2.2.3
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
pip : 25.1.1
Cython : 0.29.33
sphinx : None
IPython : 8.10.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.11.2
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.5.0
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.2
lxml.etree : 4.9.2
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.3
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 17.0.0
pyreadstat : None
pytest : 7.4.3
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
sqlalchemy : 2.0.30
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.1
qtpy : N/A
pyqt5 : None

@frbelotto frbelotto added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 27, 2025
@frbelotto frbelotto changed the title BUG: Mask changing value despite of no True retorn BUG: Mask changing value despite of no True return May 27, 2025
@frbelotto
Copy link
Author

I think that my issue is similar to the Issue 60729

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

1 participant