我有一个返回pd.DataFrame
输出的API。我使用.to_json(orient="records")
来获得以下格式的结果:
[
{"prob":0.8471122148,"name":"apple"},
{"prob":0.1276400363,"name":"banana"},
{"prob":0.0072438974,"name":"pears"}
]
如何进一步修改结果以使其变为以下格式?
{
"apple": 0.8471122148,
"banana":0.1276400363,
"pears":0.0072438974
}