From 4285be42b87e0807e71e23bf04521ec4aeacea71 Mon Sep 17 00:00:00 2001 From: lyj182 <149088866+lyj182@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:47:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20analysis.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analysis.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/analysis.py b/analysis.py index 598d96e..73d766e 100644 --- a/analysis.py +++ b/analysis.py @@ -13,12 +13,22 @@ sheet4 = workbook.parse('中央国家行政机关参照公务员法管理事业 def find_environment_rows(sheet): return sheet[sheet['专业'].str.contains('环境科学')] +def find_ecology_rows(sheet): + return sheet[sheet['专业'].str.contains("生态")] + # 在新工作表中合并包含环境科学的行 -environment_rows = pd.concat([find_environment_rows(sheet1), find_environment_rows(sheet2), - find_environment_rows(sheet3), find_environment_rows(sheet4)]) +# environment_rows = pd.concat([find_environment_rows(sheet1), find_environment_rows(sheet2), +# find_environment_rows(sheet3), find_environment_rows(sheet4)]) + +ecology_rows = pd.concat([find_ecology_rows(sheet1), find_ecology_rows(sheet2), + find_ecology_rows(sheet3), find_ecology_rows(sheet4)]) # 创建一个新的工作薄并将结果写入其中 -with pd.ExcelWriter('environment_data.xlsx', engine='openpyxl') as writer: - environment_rows.to_excel(writer, sheet_name='Environment Data', index=False) +# with pd.ExcelWriter('environment_data.xlsx', engine='openpyxl') as writer: +# environment_rows.to_excel(writer, sheet_name='Environment Data', index=False) -print("包含环境科学的行已写入新工作薄 'environment_data.xlsx'") + +with pd.ExcelWriter('ecology_data.xlsx', engine='openpyxl') as writer: + ecology_rows.to_excel(writer, sheet_name='ecology Data', index=False) + +# print("包含环境科学的行已写入新工作薄 'environment_data.xlsx'")