利用pandas合并多个excel的方法示例
作者:data_learn 时间:2021-05-28 00:02:00
具体方法:
1使用panda read_excel 方法加载excel
2使用concat将DataFrame列表进行拼接
3然后使用pd.ExcelWriter对象和to_excel将合并后的DataFrame保存成excel
方法很简单很使用,下面是代码和excel图片
参考文档pandas.DataFrame.to_excel
import pandas as pd
file1='C:/Users/Administrator/Desktop/00/1.xlsx'
file2='C:/Users/Administrator/Desktop/00/3.xlsx'
file3='C:/Users/Administrator/Desktop/00/21.xlsx'
file=[file1,file2,file3]
li=[]
for i in file:
li.append(pd.read_excel(i))
writer = pd.ExcelWriter('C:/Users/Administrator/Desktop/00/output.xlsx')
pd.concat(li).to_excel(writer,'Sheet1',index=False)
writer.save()
如下图:
来源:https://blog.csdn.net/data_learn/article/details/78609179
标签:pandas,合并,excel
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
一文带你吃透Python中的os和sys模块
2022-01-04 20:42:55
![](https://img.aspxhome.com/file/2023/0/76010_0s.png)
深入了解python的函数参数
2023-07-24 08:19:01
![](https://img.aspxhome.com/file/2023/2/59472_0s.png)
概念性产品设计
2008-06-11 12:57:00
Python中用max()方法求最大值的介绍
2021-12-08 09:33:06
php使用curl抓取qq空间的访客信息示例
2023-10-30 05:50:32
python文件的读取、写入与删除
2022-01-21 21:17:12
![](https://img.aspxhome.com/file/2023/6/75336_0s.png)
js弹出新窗口而不会被浏览器阻止的方法
2010-04-06 12:38:00
ASP中的301跳转和302跳转
2008-08-06 18:40:00
触手生春【4.13】CSS中的伪元素选择符
2008-11-11 13:10:00
![](https://img.aspxhome.com/file/UploadPic/200811/11/o2008113223147-93s.jpg)
从MySQL导大量数据的程序实现方法
2009-03-06 14:34:00
Python基于numpy模块实现回归预测
2022-11-26 19:25:32
![](https://img.aspxhome.com/file/2023/2/82592_0s.png)
用SQL Server事件探查器创建跟踪
2009-02-24 17:45:00
基于python3+OpenCV实现人脸和眼睛识别
2023-06-08 04:20:14
![](https://img.aspxhome.com/file/2023/7/66357_0s.jpg)
python获取指定时间段内特定规律的日期列表
2021-02-09 02:16:25
![](https://img.aspxhome.com/file/2023/0/76930_0s.png)
基于Python的微信机器人开发 微信登录和获取好友列表实现解析
2021-09-14 17:03:46
![](https://img.aspxhome.com/file/2023/6/64716_0s.png)
python 的 openpyxl模块 读取 Excel文件的方法
2023-02-23 14:41:56
![](https://img.aspxhome.com/file/2023/6/67426_0s.jpg)
WEB2.0网页制作标准教程(3)定义语言编码
2007-11-13 13:23:00
教你在MySQL 5.0以上版本中配置主从库
2009-01-04 13:17:00
PHP入门基础之注释的写法
2023-10-20 07:26:17
细化解析:MySQL 服务器究竟有多稳定?
2009-01-14 11:55:00