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

相关推荐
Maxwell_li11 小时前
新冠检测例子学习查准率和召回率
学习·机器学习·数据分析·回归·numpy·pandas
渡我白衣4 小时前
Python 与数据科学工具链入门:NumPy、Pandas、Matplotlib 快速上手
人工智能·python·机器学习·自然语言处理·numpy·pandas·matplotlib
IT北辰1 天前
用 Python 自动解析药品规格并计算包装总容量 —— pandas + 正则实战
开发语言·python·pandas
lbb 小魔仙1 天前
Python 读取 Excel 文件:openpyxl 与 pandas 实战对比
python·excel·pandas
Amber_371 天前
数据分析之(MySQL+普通程序) VS (Python的NumPy/Pandas)
python·mysql·数据分析·numpy·pandas
Lucky高2 天前
Pandas库实践3_索引
开发语言·python·pandas
墨上烟雨2 天前
Pandas读写CSV、Excel、JSON文件
pandas
Serendipity_Carl3 天前
京东手机销售数据分析: 从数据清洗到可视化仪表盘
python·数据分析·pandas·pyecharts
一位代码4 天前
pandas | 查看数据特征的常见属性及方法
pandas
墨上烟雨4 天前
Pandas 数据结构 - DataFrame
pandas