-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
Code Sample, a copy-pastable example if possible
import numpy as np
import pandas as pd
print(pd.DataFrame([1]).to_json(indent=4))
outputs
{
"0":{
"0":1
}
}
Problem description
Any JSON prettyfier (including bare VS Code) wants to replace all :
by :
. So output of to_json
should behave as json.dump
does, at least when indent is not None
(in which case the user clearly does not care about file size):
If specified, separators should be an (item_separator, key_separator) tuple.
The default is(', ', ': ')
if indent is None and(',', ': ')
otherwise.
To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.
Expected Output
{
"0": {
"0": 1
}
}
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.8.2.final.0
python-bits : 64
OS : Linux
OS-release : 4.12.14-lp151.28.32-default
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.3
numpy : 1.18.2
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 46.1.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.8
lxml.etree : 4.5.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : 4.8.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.0
matplotlib : 3.2.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : 1.2.8
numba : None