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

相关推荐
cui_ruicheng2 小时前
Python数据分析(十四):Pandas 数据可视化
python·信息可视化·数据分析·pandas
lkx097882 天前
01-数据分析入门-Pandas实战
数据挖掘·数据分析·pandas
淼澄研学4 天前
Python自动化办公实操:基于pandas与requests的5个提效场景解析
python·自动化·pandas
Y38153266210 天前
serpbase + Pandas + Jupyter 数据分析实战
jupyter·数据分析·pandas
元Y亨H11 天前
numpy与pandas 的介绍
numpy·pandas
小大宇12 天前
python pandas dataFrame sqlAlchemy案例
python·pandas
chouchuang13 天前
day-040-Pandas可视化与实战
pandas
chouchuang16 天前
day-037-Pandas数据读取
pandas
benchmark_cc17 天前
如何用 Python 进行多周期 K 线合成与时区对齐?基于 QuantDash 与 Pandas 的量化数据清洗实战(附 GitHub 源码)
开发语言·python·github·盯盘·pandas·quantdash·量化数据
梅雅达编程笔记19 天前
零基础学 Python 第14章 | 模块、包与第三方库
开发语言·python·django·numpy·pandas