-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
When trying to convert a DataFrame that contains Path objects to json it crashes:
import pandas as pd
from pathlib import Path
df = pd.DataFrame({'a': [Path('m1')]})
df.to_json()
output
Traceback (most recent call last):
File "<ipython-input-67-05359facf0e6>", line 1, in <module>
df.to_json()
File "/home/rikard/.local/lib/python3.7/site-packages/pandas/core/generic.py", line 2305, in to_json
indent=indent,
File "/home/rikard/.local/lib/python3.7/site-packages/pandas/io/json/_json.py", line 84, in to_json
indent=indent,
File "/home/rikard/.local/lib/python3.7/site-packages/pandas/io/json/_json.py", line 144, in write
self.indent,
File "/home/rikard/.local/lib/python3.7/site-packages/pandas/io/json/_json.py", line 244, in _write
indent,
File "/home/rikard/.local/lib/python3.7/site-packages/pandas/io/json/_json.py", line 166, in _write
indent=indent,
OverflowError: Maximum recursion level reached
It might be that Path objects are not supported by to_json, but I wouldn't expect an infinite recursion.
INSTALLED VERSIONS
commit : f2ca0a2
python : 3.7.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.3.0-64-generic
Version : #58-Ubuntu SMP Fri Jul 10 19:33:51 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.1
numpy : 1.16.2
pytz : 2019.2
dateutil : 2.7.3
pip : 18.1
setuptools : 41.1.0
Cython : None
pytest : 3.7.4
hypothesis : None
sphinx : 2.4.4
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.10.2
pandas_datareader: None
bs4 : 4.9.0
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.1.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.1.0
sqlalchemy : None
tables : None
tabulate : None
xarray : 0.14.1
xlrd : None
xlwt : None
numba : None