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

相关推荐
飞梦工作室2 天前
突破 pandas 瓶颈:实时读写 Excel 与超透视汇总函数的双维解决方案
python·excel·pandas
Python大数据分析@3 天前
Vaex :突破pandas,快速分析100G大数据量
pandas
AI小云3 天前
【数据操作与可视化】Pandas数据处理-Series数据结构
开发语言·数据结构·python·numpy·pandas
小兔崽子去哪了5 天前
Numpy、Panads
python·numpy·pandas
一晌小贪欢6 天前
Pandas操作Excel使用手册大全:从基础到精通
开发语言·python·自动化·excel·pandas·办公自动化·python办公
CodeLongBear7 天前
Python数据分析 -- Pandas基础入门学习笔记:从核心概念到实操代码
python·conda·pandas
njxiejing8 天前
Python pandas基础:Series数据操作详解
数据结构·pandas
F_D_Z12 天前
DataFrame中.iloc 属性
pandas·dataframe·.iloc
husterlichf13 天前
pandas__unstack方法与set_index详解
数据挖掘·数据分析·pandas