Convert Pandas DataFrame to JSON format

前端 未结 7 1719
野性不改
野性不改 2020-11-30 01:45

I have a Pandas DataFrame with two columns – one with the filename and one with the hour in which it was generated:

 File       Hour
  F1               


        
7条回答
  •  醉梦人生
    2020-11-30 02:20

    I think what the OP is looking for is:

    with open('temp.json', 'w') as f:
        f.write(df.to_json(orient='records', lines=True))
    

    This should do the trick.

提交回复
热议问题