python 实现读取一个excel多个sheet表并合并的方法
作者:小墨青 时间:2023-06-25 20:11:51
如下所示:
import xlrd
import pandas as pd
from pandas import DataFrame
DATA_DIR = 'E:/'
excel_name = '%s2017.xls' % DATA_DIR
wb = xlrd.open_workbook(excel_name)
# print(wb)
# 获取workbook中所有的表格
sheets = wb.sheet_names()
# print(sheets)
# 循环遍历所有sheet
df_28 = DataFrame()
for i in range(len(sheets)):
# skiprows=2 忽略前两行
df = pd.read_excel(excel_name, sheet_name=i, skiprows=2, index=False, encoding='utf8')
df_28 = df_28.append(df)
# 去除缺省值
df_28 = df_28.dropna()
df_28 = df_28.reset_index(drop=True)
print(len(df_28))
来源:https://blog.csdn.net/qq_34218221/article/details/78974541
标签:python,excel,sheet,合并
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#实现按数据库邮件列表发送邮件的方法
2024-01-24 02:37:32
Python开根号的几种方式详解
2021-07-10 20:37:34
![](https://img.aspxhome.com/file/2023/5/75935_0s.png)
golang操作rocketmq的示例代码
2024-04-26 17:25:41
数据库备份过程中经常遇到的九种情况
2008-12-26 16:38:00
sqlserver分页查询处理方法小结
2024-01-13 19:50:23
python之tensorflow手把手实例讲解斑马线识别实现
2021-11-11 05:53:19
![](https://img.aspxhome.com/file/2023/0/68460_0s.png)
python pandas时序处理相关功能详解
2023-07-25 12:03:18
pandas基础 Series与Dataframe与numpy对二进制文件输入输出
2023-10-18 08:20:13
![](https://img.aspxhome.com/file/2023/4/118284_0s.png)
Python函数式编程之返回函数实例详解
2021-10-31 03:46:26
![](https://img.aspxhome.com/file/2023/2/80402_0s.png)
MySQL中USING 和 HAVING 用法实例简析
2024-01-14 22:07:47
mybatis连接MySQL8出现的问题解决方法
2024-01-22 08:27:59
Python Tkinter实例——模拟掷骰子
2022-09-17 09:51:07
![](https://img.aspxhome.com/file/2023/7/78487_0s.png)
仿dw8代码折叠功能的HTML编辑器
2008-04-29 21:19:00
sql server2008调试存储过程的完整步骤
2024-01-22 04:12:57
![](https://img.aspxhome.com/file/2023/1/125701_0s.png)
jupyter notebook保存文件默认路径更改方法汇总(亲测可以)
2023-01-12 09:05:07
![](https://img.aspxhome.com/file/2023/5/131635_0s.jpg)
javascript编程起步(第六课)
2024-06-05 10:01:41
Go语言Elasticsearch数据清理工具思路详解
2023-08-07 06:29:49
![](https://img.aspxhome.com/file/2023/6/93656_0s.jpg)
python中while循环语句用法简单实例
2021-12-03 22:34:44
Python写的贪吃蛇游戏例子
2023-06-26 15:50:55
python批量查询、汉字去重处理CSV文件
2023-01-20 08:27:17