I want to convert the below dataframe into the json formation as mentioned:
Dataframe:
Desired Ouput:
{"Adam": [{"name": "ABC", "y": 2.0}, {"name": "DEF", "y": 5}],
"John": [{"name": "GHI", "y": 29.01}, {"name": "FMI", "y": 219.77}]}
I tried creating the index of Party column and use df.to_json(orient="index") but its failing due to duplicate in index columns (Party column). Can someone please help.
