master
lyj182 2023-10-26 23:30:26 +08:00
commit a20dc1c7cd
4 changed files with 23 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
./venv

22
analysis.py Normal file
View File

@ -0,0 +1,22 @@
import pandas as pd
# 读取工作薄中的四张表格
workbook = pd.ExcelFile("国考岗位修改.xls")
sheet1 = workbook.parse('中央党群机关')
sheet2 = workbook.parse('中央国家行政机关(本级)')
sheet3 = workbook.parse('中央国家行政机关省级以下直属机构')
sheet4 = workbook.parse('中央国家行政机关参照公务员法管理事业单位')
# 找出包含环境科学的行
def find_environment_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)])
# 创建一个新的工作薄并将结果写入其中
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'")

BIN
environment_data.xlsx Normal file

Binary file not shown.

BIN
国考岗位修改.xls Normal file

Binary file not shown.