Numpy、Pandas 笔记(二)
将一个excel中的多个sheet表合并
通过pandas合并后
代码如下所示:(P.S. 建议jupyter)
1 import numpy as np 2 import pandas as pd 3 import matplotlib.pyplot as plt 4 from pandas import DataFrame 5 import xlrd 6 7 # df = pd.read_excel('./2019-nCoV.xlsx', '02-21') 8 # df 9 wb = xlrd.open_workbook('./2019-nCoV.xlsx') 10 wb 11 12 # 获取workbook中所有的表格 13 sheets = wb.sheet_names() 14 sheets 15 16 # 循环遍历所有sheet 17 df_ = DataFrame() 18 for i in range(len(sheets)): 19 df = pd.read_excel('./2019-nCoV.xlsx', sheet_name=i) 20 df_ = df_.append(df) 21 22 #df_ 23 24 25 df_.to_excel('China_2019-nCoV.xlsx')
参考链接:https://www.jb51.net/article/156099.htm