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

相关推荐
F_D_Z2 天前
DataFrame中.iloc 属性
pandas·dataframe·.iloc
husterlichf3 天前
pandas__unstack方法与set_index详解
数据挖掘·数据分析·pandas
wudl55666 天前
Pandas-之数据可视化
信息可视化·数据分析·pandas
万粉变现经纪人7 天前
如何解决 pip install 安装报错 [WinError 32] 文件被占用(杀毒/占用进程)问题
python·pycharm·flask·beautifulsoup·bug·pandas·pip
文人sec7 天前
使用python-pandas-openpyxl编写运营查询小工具
开发语言·python·pandas
咋吃都不胖lyh7 天前
比较两个excel文件的指定列是否一致
爬虫·python·pandas
IT小哥哥呀9 天前
Python实用技巧:批量处理Excel数据并生成销售报表(含实战案例)
python·pandas·数据可视化·数据处理·报表生成·excel自动化·办公神器
Serendipity_Carl10 天前
爬虫数据清洗可视化链家房源
python·pandas·matplotlib
husterlichf10 天前
pandas___get_dummies详解
pandas