将包含列中列表的熊猫数据框另存为json

时间:2019-12-22 15:34:18

标签: python json pandas

我有一个熊猫df,它在某些列中保存值列表,例如:

ID   Unique_ID  MeSH_heading    tree_num    term_concepts   term_strings
4084    D001932 Brain Neoplasms [C04.588.614.250.195, C10.228.140.211, C10.551...   [Brain Neoplasms, Brain Cancer, Neoplasms, Int...   

df有几个这样的行。

如何将其转换为JSON格式,如下所示:

{
    "id": 4084,
    "Unique_ID": D001932,
    "MeSH_heading": "Brain Neoplasms",
    "tree_num": [
        "C04.588.614.250.195",
        "C10.228.140.211",
        "C10.551"
    ]
}

有什么建议吗?谢谢!

0 个答案:

没有答案