Convert Pandas DataFrame to JSON format

前端 未结 7 1643
野性不改
野性不改 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:36

    convert data-frame to list of dictionary

    list_dict = []
    
    for index, row in list(df.iterrows()):
        list_dict.append(dict(row))
    

    save file

    with open("output.json", mode) as f:
        f.write("\n".join(str(item) for item in list_dict))
    
    0 讨论(0)
提交回复
热议问题