-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: pd.DataFrame.from_dict with a numpy masked array of dtype=object produces NaN instead of None. #51872
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
Comments
The default value for masked variable in numpy is None , but in pandas it is np.nan . Chaning defailt value in pandas from np.nan to None might need lot of changes. |
Thanks @yeshsurya, and totally understood. Without understanding pandas impl details, two possible suggestions:
Thoughts? |
… produces NaN instead of None. pandas-dev#51872
… produces NaN instead of None. pandas-dev#51872
… produces NaN instead of None. pandas-dev#51872
take |
… produces NaN instead of None. pandas-dev#51872
Hi! Checking if this fix got merged back to the main repo? |
Not yet ; Some with merge privileages need to review and merge. |
Uh oh!
There was an error while loading. Please reload this page.
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
The "None" from a numpy masked array in a dtype=object is being converted to a NaN when using pd.DataFrame.from_dict.
This is causing weird behavior in duckdb: duckdb/duckdb#4066
Expected Behavior
Ideally, this "None" from numpy should be a "None" in the pandas dataframe, not a NaN since this is an object (string) dtype column.
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.9.13.final.0
python-bits : 64
OS : Darwin
OS-release : 22.3.0
Version : Darwin Kernel Version 22.3.0: Thu Jan 5 20:49:43 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T8103
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.3
numpy : 1.22.4
pytz : 2022.7
dateutil : 2.8.2
setuptools : 65.6.3
pip : 22.3.1
Cython : None
pytest : 7.2.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader: None
bs4 : 4.11.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2023.1.0
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
snappy : None
sqlalchemy : 2.0.0rc1
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : 0.19.0
tzdata : None
The text was updated successfully, but these errors were encountered: