python 实现读取一个excel多个sheet表并合并的方法
作者:互联网
如下所示:
importxlrd
importpandas as pd
frompandas importDataFrame
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()
fori inrange(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))
标签:sheet,name,python,excel,表并,df,print,28 来源: https://blog.csdn.net/qq_40925239/article/details/89738112