pandas: dataframe转字典,并设置key

解决方案

res = df_by_monthly.set_index('recruit_resign_month').T.to_dict('list')
print(res)

上述代码是转为列表形式
image

转为字典形式

res = df_by_monthly.set_index('recruit_resign_month').T.to_dict()
print(res)

image

参考链接

https://www.cxybb.com/article/zx1245773445/103480750
https://blog.csdn.net/zx1245773445/article/details/103480750
https://blog.csdn.net/zx1245773445/article/details/103480750

posted @ 2022-04-26 11:26  胸怀丶若谷  阅读(313)  评论(0编辑  收藏  举报