乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > excel分页-Python用起来,Excel百万数据集分类分页,只需一分钟!

excel分页-Python用起来,Excel百万数据集分类分页,只需一分钟!

作者:乔山办公网日期:

返回目录:excel表格制作

import pandas as pddef read_excel(my_excel_path,target_path): df = pd.read_excel(my_excel_path, index_col=None, headers = 0, na_values=['NA']) pd.set_option('display.unicode.ambiguous_as_wide', True)#解决列对齐问题 pd.set_option('display.unicode.east_asian_width', True)#解决列对齐问题 pd.set_option('display.width', 180)# 150,设置打印宽度 pd.set_option('display.max_rows', 100) # 打印最大行数 pd.set_option('display.max_columns', 40) # 打印最大列数 df_group=df.groupby(["单位"]).count() sheets=df_group.index.size print(sheets) writer = pd.ExcelWriter(target_path) for sheet in range(0,sheets ): select=df_group.index[sheet] sheetname = df_group.index[sheet]+str(sheet+1) df_sheets = df[df.单位 == select] # print(df3) df_sheets.to_excel(writer, sheetname,index=None) writer.save()if __name__ == '__main__': print('Program is running...') my_excel_path = r'C:UserscyxDesktop2018XXX.xls' target_path = r'C:UserscyxDesktop2018XXXX.xls' read_excel(my_excel_path,target_path) print('Success!')

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网