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 天前
本地已有一年历史 K 线,第二天更新别只拉“昨天一天”
python·数据分析·pandas·量化交易·股票数据·quantdash
正在走向自律3 天前
AI数据分析与可视化:从基础到应用实践
服务器·人工智能·python·机器学习·数据分析·pandas
ctlover3 天前
Pandas进阶
人工智能·机器学习·pandas
程序员清风3 天前
数据类型转换与日期时间处理
数据结构·pandas
for_ever_love__4 天前
Pandas 基础——用 DataFrame 管理训练数据与实验记录
数据分析·pandas·大模型开发·dataframe
benchmark_cc5 天前
A股量化尾盘筛选对数据时效敏感:行情链路变慢时先排查哪里?
python·数据分析·pandas·量化交易·股票数据·quantdash
梅雅达编程笔记5 天前
07-Pandas数据清洗:
pandas·drop_duplicates·dropna·fillna·to_numeric·to_datetime·清洗流程
for_ever_love__5 天前
电商订单数据清洗实战——Pandas 处理缺失值、重复单与异常金额
python·数据分析·pandas·数据清洗
weixin_440401695 天前
质朴的爬虫+数据处理
爬虫·python·数据分析·pandas
程序员清风6 天前
pandas 核心数据结构:Series 与 DataFrame
数据结构·pandas