Pandas:将pivot转换为JSON

2024-09-29 02:22:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下熊猫支点

Apple    Green    5
         Red      3
         Yellow   4
Grapes   Red      1
         Green    3

并希望将此数据转换为JSON,如下所示:

^{pr2}$

我该怎么做?我尝试过使用json(),它返回不同的格式。在


Tags: 数据jsonapple格式greenredyellow支点