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

相关推荐
程序大视界14 小时前
【Python系列课程】Pandas(四):数据统计与排序——describe、sort_values、sample
开发语言·python·pandas
知识分享小能手1 天前
数据预处理入门学习教程,从入门到精通,数据获取 — 知识点详解与案例代码(4)
python·学习·pandas
乔江seven2 天前
【python 数据分析】 Numpy、pandas、matplotlib
数据分析·numpy·pandas
石工记4 天前
CTO如何落地AI?从0到1的实战路径
人工智能·python·django·flask·numpy·pandas·pyqt
weixin_468466854 天前
Data-Engineering-Zoomcamp 新手实战指南
python·自动化·pandas·编程·数据处理
威尔逊·柏斯科·希伯理7 天前
机器学习第一天(共12天)
人工智能·python·机器学习·conda·numpy·pandas·matplotlib
星越华夏7 天前
Polars中导入excel文件
python·pandas
我材不敲代码9 天前
零基础快速上手 Pandas 数据处理
pandas
星越华夏9 天前
pandas中时间处理
pandas
Cloud_Shy61810 天前
Python 数据分析基础入门:《Excel Python:飞速搞定数据分析与处理》学习笔记系列(第十二章 用户定义函数 下篇)
python·plotly·数据分析·excel·numpy·pandas