# Author:ShowTimEimport xlrdimport sysfrom xlutils.copy import copyimport xlwtimport pandas as pd xlsx = xlrd.open_workbook(‘../智能跟单/excel/6.03实时跟单完成情况 - 副本.xls‘, formatting_info=True) output_workbook = xlwt.Workbook()output_worksheet = output_workbook.add_sheet(‘完成情况_output‘) for row_index in range(xlsx.sheet_by_name(‘完成情况‘).nrows): for column_index in range(xlsx.sheet_by_name(‘完成情况‘).ncols): output_worksheet.write(row_index, column_index, xlsx.sheet_by_name(‘完成情况‘).cell_value(row_index, column_index))output_workbook.save(‘完成情况_output.xls‘) xlsx_frame = pd.read_excel(‘完成情况_output.xls‘, ‘完成情况_output‘)# xlsx_frame_value_meets_condition = xlsx_frame[xlsx_frame[‘异常发生率‘].astype(float) > 0.2]xlsx_frame1 = xlsx_frame.copy()# xlsx_frame1 = xlsx_frame.Txlsx_frame1.drop(labels=‘6.3温州实时跟单完成情况‘, axis=1, inplace=True)xlsx_frame1.drop(labels=0, axis=0, inplace=True)xlsx_frame1.drop(columns=[‘Unnamed: 12‘, ‘Unnamed: 13‘, ‘Unnamed: 14‘, ‘Unnamed: 15‘], axis=1, inplace=True) print(xlsx_frame1.shape)print(‘*‘ * 80)print(xlsx_frame1.head()) writer = pd.ExcelWriter(‘完成情况_output1.xls‘)xlsx_frame1.to_excel(writer, sheet_name=‘完成情况_output1‘, index=False)writer.save()writer.close()
# 写入不能直接去写,每一个动作都是调用一个对象。
原文地址:https://www.cnblogs.com/nimakk/p/10993378.html
时间: 2024-10-19 08:49:01