Skip to content
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: OverflowError when JSON serializing a dataframe/series with PeriodArray variable #58236

Closed
3 tasks done
bquistorff opened this issue Apr 12, 2024 · 2 comments
Closed
3 tasks done
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@bquistorff
Copy link
Contributor

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
pd.DataFrame({'Date':pd.period_range("2000-01-01", periods=2)}).to_json()  # one error
pd.Series(pd.period_range("2000-01-01", periods=2)).to_json()  # another error

Issue Description

Both lines give the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pandas/pandas/core/generic.py", line 2542, in to_json
    return json.to_json(
  File "/home/pandas/pandas/io/json/_json.py", line 201, in to_json
    ).write()
  File "/home/pandas/pandas/io/json/_json.py", line 252, in write
    return ujson_dumps(
OverflowError: Maximum recursion level reached

Note a PeriodIndex is fine (a similar bug, #46683, was fixed).

Expected Behavior

Valid json output.

Installed Versions

INSTALLED VERSIONS

commit : 4fe49b1
python : 3.10.8.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.146.1-microsoft-standard-WSL2
Version : #1 SMP Thu Jan 11 04:09:03 UTC 2024
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 3.0.0.dev0+706.g4fe49b160e
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 63.2.0
pip : 24.0
Cython : 3.0.10
pytest : 8.1.1
hypothesis : 6.100.1
sphinx : 7.2.6
blosc : None
feather : None
xlsxwriter : 3.2.0
lxml.etree : 5.2.1
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : 2.9.9
jinja2 : 3.1.3
IPython : 8.23.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.3.8
fastparquet : 2024.2.0
fsspec : 2024.3.1
gcsfs : 2024.3.1
matplotlib : 3.8.4
numba : 0.59.1
numexpr : 2.10.0
odfpy : None
openpyxl : 3.1.2
pyarrow : 15.0.2
pyreadstat : 1.2.7
python-calamine : None
pyxlsb : 1.0.10
s3fs : 2024.3.1
scipy : 1.13.0
sqlalchemy : 2.0.29
tables : 3.9.2
tabulate : 0.9.0
xarray : 2024.3.0
xlrd : 2.0.1
zstandard : 0.22.0
tzdata : 2024.1
qtpy : None
pyqt5 : None

@bquistorff bquistorff added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 12, 2024
@asishm
Copy link
Contributor

asishm commented Apr 12, 2024

Duplicate of #55490

@mroeschke
Copy link
Member

Thanks for the find @asishm. Closing as a duplicate

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

3 participants