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

相关推荐
淼澄研学1 天前
Python自动化办公实操:基于pandas与requests的5个提效场景解析
python·自动化·pandas
Y3815326627 天前
serpbase + Pandas + Jupyter 数据分析实战
jupyter·数据分析·pandas
元Y亨H8 天前
numpy与pandas 的介绍
numpy·pandas
小大宇9 天前
python pandas dataFrame sqlAlchemy案例
python·pandas
chouchuang10 天前
day-040-Pandas可视化与实战
pandas
chouchuang13 天前
day-037-Pandas数据读取
pandas
benchmark_cc14 天前
如何用 Python 进行多周期 K 线合成与时区对齐?基于 QuantDash 与 Pandas 的量化数据清洗实战(附 GitHub 源码)
开发语言·python·github·盯盘·pandas·quantdash·量化数据
梅雅达编程笔记16 天前
零基础学 Python 第14章 | 模块、包与第三方库
开发语言·python·django·numpy·pandas
梅雅达编程笔记16 天前
零基础学 Python 第15章 | 类与对象:面向对象编程入门
开发语言·python·django·numpy·pandas
benchmark_cc16 天前
Python 量化核心基础:前复权、后复权与不复权有什么区别?基于 QuantDash 的数据处理与回测避坑指南
开发语言·python·pandas·量化策略·量化交易·quantdash