pandas DataFrame转成字典

目录

dict形式

原数据

DateFrame.to_dict()

python 复制代码
pd.read_excel(r"D:\Users\admin\Desktop\授信额度使用.xlsx").to_dict()


list形式

DateFrame.to_dict('list')

python 复制代码
pd.read_excel(r"D:\Users\admin\Desktop\授信额度使用.xlsx").to_dict('list')

records形式

records形式是将每行转换成一个对应的字典

df.to_dict('records')

split形式

split形式比较特殊,其输出字典包含三个key值,分别为index、columns和data,分别对应行名、列名和数据。

参考文档:
https://blog.csdn.net/m0_59541412/article/details/131324515

相关推荐
码界筑梦坊17 小时前
118-基于Python的游戏账号数据可视化分析系统
python·游戏·信息可视化·毕业设计·pandas·fastapi
川冰ICE21 小时前
Python爬虫实战⑲|Pandas数据合并与重塑,多数据源整合
爬虫·python·pandas
Cloud_Shy6181 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第八章 使用读写包操作 Excel 文件 上篇)
python·数据分析·excel·pandas
Cloud_Shy6182 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第九章 Excel 自动化 上篇)
python·数据分析·excel·numpy·pandas
Cloud_Shy6182 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第八章 使用读写包操作 Excel 文件 下篇)
python·数据分析·excel·numpy·pandas
没有不重的名么2 天前
pandas用法
pandas
Cloud_Shy6182 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第九章 Excel 自动化 下篇)
python·数据分析·excel·numpy·pandas
川冰ICE3 天前
Python爬虫实战⑱|Pandas分组聚合,一键生成统计报表
爬虫·python·pandas
deephub4 天前
Feature Engineering 实战:Pandas + Scikit-learn的机器学习特征工程的完整代码示例
人工智能·python·机器学习·pandas·scikit-learn
星空椰4 天前
Python 使用飞书 API 获取子部门列表接口信息
python·pandas·飞书