-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: Creating a string column on a mask results in NaN being stringyfied and potentially truncated based on the 'maxchar' value of the column #56204
Comments
Seems to be a regression (haven't run a bisect yet). Was working as expected in 2.0.3 |
I've also come across this, running on Mac OS X. The change seems to occur from release 2.1.2 onwards (2.1.1 is ok). Expanded Example
Under pandas <= 2.1.1 get expected result where all four columns set from a partial mask have NaN for the undefined odd rows:
Swapping to pandas >= 2.1.2 the string or "char" are both turned into (truncated strings):
|
Thanks @richard-younergy for narrowing it down further. Bisect seems to give (not sure if I bisected correctly using meson or not) #55249 cc @MarcoGorelli
|
thanks for the report, this looks pretty bad, will take a loook |
Thanks for the help @richard-younergy. I had my suspicions as well on 2.1.2 as I upgraded from 2.1.1 to 2.1.3 and got the bug. |
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
Issue Description
When partially defining a column on a mask, rows not included in the mask should be set to NaN. With the new way of handling string in pandas, it seems that NaN values are cast to string ("nan") and then the space optimisation applying a
maxchar
on the column is potentially truncating the "nan" to "na" or even "n".Expected Behavior
// Result //
a b c
0 1 3 1
1 2 4 NaN
Installed Versions
INSTALLED VERSIONS
commit : 2a953cf
python : 3.10.11.final.0
python-bits : 64
OS : Linux
OS-release : 4.18.0-477.27.1.el8_8.x86_64
Version : #1 SMP Thu Aug 31 10:29:22 EDT 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.3
numpy : 1.26.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 68.2.0
pip : 23.2.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: