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

相关推荐
databook6 小时前
经常听到的透视表是干什么的?
python·数据分析·pandas
benchmark_cc2 天前
A 股、港股、美股如何建立统一的标的主数据格式?
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
benchmark_cc2 天前
用 00700.HK 做港股行情清洗:字段核对、校验与个人量化开发实践
python·数据分析·pandas·量化交易·股票数据·quantdash
第九序言T2 天前
数据分析岗 Pandas 面试题 20 道(上):概念与读代码
python·数据分析·pandas·数据处理
2601_966949652 天前
如何封装 qd.klines.batch(),让批量 K 线查询函数在多个策略中复用?
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
Blockbuater_drug2 天前
《经典机器学习实战》第 2 课:回归入门——环境、工具与数据准备
线性回归·pandas·scikit-learn·数据可视化·数据清洗·最小二乘法·conda环境
烂蜻蜓3 天前
Pandas入门教程(十六):常用函数速查手册——读写、清洗、选择、排序、分组与统计
pandas
quantdash_cc3 天前
个人开发者用 QuantDash 读取港股行情:00700.HK 的 Python 函数封装与校验实践
python·数据分析·pandas·量化交易·股票数据·quantdash
databook4 天前
Pandas 与 Polars:语法、性能和资源占用方面的对比
python·数据分析·pandas
桑年4 天前
四、Pandas数据处理
人工智能·python·线性代数·pandas·数据可视化·数据处理