【发布时间】:2016-04-20 02:24:27
【问题描述】:
我想使用从 R 输出的 JSON 文件创建一个treemap(或 Python,如果我真的不能在 R 中执行此操作,我可以切换到 Python 吗?)。这 数据看起来像 this:
cat type pop
Buddhism Other 116237936
Christianity Anglican 36955033
Christianity Catholic 391332035
Christianity Orthodox 98501171
Christianity Other 13674466
Christianity Mahayana 160887585
Islam Ibadhi 62273219
Islam Shia 19436742
Islam Sunni 49050320
Judaism Conservative 1426350
Judaism Orthodox 856827
Judaism Other 7796835
Judaism Reform 1929388
我需要 json 看起来像 ...
{"name": "Buddhism",
"children":
{"name": "Other", "size": 116237936}
},
{
"name": "Christianity",
"children": [
{"name": "Anglican", "size": 36955033},
{"name": "Catholic", "size": 391332035},
{"name": "Orthodox", "size": 98501171},
{"name": "Other", "size": 13674466},
{"name": "Mahayana", "size": 160887585}
]
} ...
【问题讨论】:
-
也许这篇stackoverflow.com/questions/31339805/… 的帖子会有所帮助