将Pandas Dataframe保存为JSON

时间:2018-10-08 10:08:58

标签: python json pandas

当我尝试将数据帧保存为json格式时。低于错误。 df的大小为70 + MB。熊猫版本:0.23.4。数据框具有90列和165K记录

df.to_json('df.json',orient ='records')

    Could not reserve memory block
Traceback (most recent call last):
  File "C:/***/validate.py", line 70, in process_data
    df.to_json('df.json', orient='records')
  File "C:\***\venv\lib\site-packages\pandas\core\generic.py", line 1891, in to_json
    index=index)
  File "C:\***\venv\lib\site-packages\pandas\io\json\json.py", line 58, in to_json
    index=index).write()
  File "C:\***\venv\lib\site-packages\pandas\io\json\json.py", line 101, in write
    self.date_format == 'iso', self.default_handler)
  File "C:\***\venv\lib\site-packages\pandas\io\json\json.py", line 156, in _write
    iso_dates, default_handler)
  File "C:\***\venv\lib\site-packages\pandas\io\json\json.py", line 112, in _write
    default_handler=default_handler
OverflowError: Could not reserve memory block

0 个答案:

没有答案