BUG: Pandas's ujson module incorrectly returns None when it reads NaN. #46627
Labels
Bug
IO JSON
read_json, to_json, json_normalize
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
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 above script has comments explaining it. The main issue is the ujson parser in pandas generates a null when it reads a NaN.
This is a bug, albeit minor because the only way you would ever notice is if you loaded a json object with nans and non-numeric members.
This is seen via the output of the above MWE:
Expected Behavior
Instead of emiting a None, the ujson parser should emit a Py_NaN when it reads nan. I have already fixed this in ujson itself, and I will submit a PR fixing it here.
Installed Versions
pandas : 1.4.2
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 57.5.0
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 : 8.2.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: