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

相关推荐
benchmark_cc1 天前
批量获取量化数据时,如何设置合理的超时和重试机制?——QuantDash 高性能实战指南
开发语言·人工智能·python·pandas·量化·quantdash
2601_966949651 天前
使用 Pandas 读取批量数据时如何避免内存溢出?QuantDash 量化数据工程师避坑指南
开发语言·python·pandas·tushare·akshare·quantdash
三十岁老牛再出发2 天前
08.18每日总结
c++·python·numpy·pandas
虎头金猫5 天前
如何在群晖NAS上通过Docker部署CloudSaver?群晖部署CloudSaver教程|聚合资源搜索并实现远程访问
运维·服务器·网络·python·docker·容器·pandas
Uncommon.6 天前
使用pandas处理csv并转为张量
pytorch·python·深度学习·pandas
STR_Liang8 天前
pandas.read_html 报错FileNotFoundError、OSError Traceback (most recent call last)
pandas
㳺三才人子9 天前
初探 Data Analysis - Matplotlib
python·plotly·pandas·matplotlib
quantdash_cc10 天前
告别自建 Requests/BS4 网页爬虫:基于 QuantDash 搭建零维保的高性能量化行情流水线
开发语言·爬虫·python·pandas·量化·quantdash
菜冻鱼10 天前
Python-sklearn-评估指标
开发语言·人工智能·python·机器学习·numpy·pandas·sklearn
菜冻鱼10 天前
Python-sklearn-模型选择
开发语言·人工智能·python·机器学习·numpy·pandas·sklearn