更新 analysis.py
parent
1f1fbe044b
commit
4285be42b8
20
analysis.py
20
analysis.py
|
|
@ -13,12 +13,22 @@ sheet4 = workbook.parse('中央国家行政机关参照公务员法管理事业
|
||||||
def find_environment_rows(sheet):
|
def find_environment_rows(sheet):
|
||||||
return sheet[sheet['专业'].str.contains('环境科学')]
|
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),
|
# environment_rows = pd.concat([find_environment_rows(sheet1), find_environment_rows(sheet2),
|
||||||
find_environment_rows(sheet3), find_environment_rows(sheet4)])
|
# 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:
|
# with pd.ExcelWriter('environment_data.xlsx', engine='openpyxl') as writer:
|
||||||
environment_rows.to_excel(writer, sheet_name='Environment Data', index=False)
|
# 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'")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue