You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to read a JSON file that has been written with orient="split" and a multi index is failing.
Pandas '0.17.0' on Python 3.5.0.
Observations
It works with orient=columns
It works when there is no multiindex
The output seems ok, the issue is probably on the decoding
Test case
import pandas as pd
df=pd.DataFrame([[1,2,3,4],[3,4,5,6],[7,8,9,10]],columns=["a","b","c","d"]).groupby(["a","b"]).sum()
df.to_json("t.json",orient="split")
pd.read_json("t.json",orient="split")
Error message
Traceback (most recent call last):
File "", line 1, in
pd.read_json("t.json",orient="split")
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\io\json.py", line 210, in read_json
date_unit).parse()
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\io\json.py", line 278, in parse
self._parse_no_numpy()
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\io\json.py", line 502, in _parse_no_numpy
self.obj = DataFrame(dtype=None, **decoded)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 277, in init
dtype=dtype)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 5102, in _arrays_to_mgr
return create_block_manager_from_arrays(arrays, arr_names, axes)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\internals.py", line 3805, in create_block_manager_from_arrays
construction_error(len(arrays), arrays[0].shape, axes, e)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\internals.py", line 3771, in construction_error
passed,implied))
ValueError: Shape of passed values is (2, 3), indices imply (2, 2)
The text was updated successfully, but these errors were encountered:
Summary
Attempting to read a JSON file that has been written with orient="split" and a multi index is failing.
Pandas '0.17.0' on Python 3.5.0.
Observations
It works with orient=columns
It works when there is no multiindex
The output seems ok, the issue is probably on the decoding
Test case
import pandas as pd
df=pd.DataFrame([[1,2,3,4],[3,4,5,6],[7,8,9,10]],columns=["a","b","c","d"]).groupby(["a","b"]).sum()
df.to_json("t.json",orient="split")
pd.read_json("t.json",orient="split")
Error message
Traceback (most recent call last):
File "", line 1, in
pd.read_json("t.json",orient="split")
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\io\json.py", line 210, in read_json
date_unit).parse()
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\io\json.py", line 278, in parse
self._parse_no_numpy()
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\io\json.py", line 502, in _parse_no_numpy
self.obj = DataFrame(dtype=None, **decoded)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 277, in init
dtype=dtype)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\frame.py", line 5102, in _arrays_to_mgr
return create_block_manager_from_arrays(arrays, arr_names, axes)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\internals.py", line 3805, in create_block_manager_from_arrays
construction_error(len(arrays), arrays[0].shape, axes, e)
File "C:\Users\mchevann\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\internals.py", line 3771, in construction_error
passed,implied))
ValueError: Shape of passed values is (2, 3), indices imply (2, 2)
The text was updated successfully, but these errors were encountered: