import pandas as pd
# 엑셀 파일 읽어오기
# df = pd.read_excel('ChatGPT_Sample_Data_Encoded_0518.xlsx')
# 변수명 변경
df = df.rename(columns={
'ID': 'worker_id',
'WC1Q02_02': 'company_worker_id',
'WC1Q03_01': 'industry_classification',
'WC1Q04': 'year_of_joining',
'WC1Q05_01': 'current_position',
'WC1Q06_01': 'contribution_to_strategy',
'WC1Q06_02': 'influence_on_decision_making',
'WC1Q06_03': 'role_in_hr_improvement',
'WC1Q06_04': 'leading_change_and_innovation',
'WC1Q06_05': 'educating_managers',
'WC1Q06_06': 'explaining_hr_policies',
'WC1Q06_07': 'trusted_by_employees',
'WC1Q06_08': 'expertise_in_field',
'WC1Q14_01': 'sufficient_training',
'WC1Q14_02': 'equal_training_opportunities',
'WC1Q14_03': 'desire_for_training',
'WC1Q14_04': 'job_relevance_of_training',
'WC1Q14_05': 'applicability_of_training',
'WC1Q14_06': 'versatility_of_training',
'WC1Q15_01': 'peer_coaching_mentoring',
'WC1Q15_02': 'supervisor_coaching_mentoring',
'WC1Q15_03': 'knowledge_sharing_among_employees',
'WC1Q15_04': 'knowledge_sharing_through_platform',
'WC1Q15_05': 'learning_through_job_rotation',
'WC1Q16_01': 'support_for_academy_tuition',
'WC1Q16_02': 'support_for_domestic_university_tuition',
'WC1Q16_03': 'support_for_domestic_graduate_school_tuition',
'WC1Q16_04': 'support_for_overseas_graduate_degree',
'WC1Q22_01': 'active_problem_solving',
'WC1Q22_02': 'diverse_experience_opportunities',
'WC1Q22_03': 'autonomy_in_work',
'WC1Q22_04': 'cooperation_and_trust',
'WC1Q22_05': 'diverse_competencies_and_experience',
'WC1Q22_06': 'good_communication',
'WC1Q23_01': 'preferential_treatment_of_talent',
'WC1Q23_02': 'clear_vision_for_hr_development',
'WC1Q23_03': 'emphasis_on_talent',
'WC1Q23_04': 'diverse_training_methods',
'WC1Q24_01': 'informing_employees',
'WC1Q24_02': 'freedom_to_express_opinions',
'WC1Q24_03': 'interdepartmental_communication',
'WC1Q24_04': 'trust_among_colleagues',
'WC1Q24_05': 'fair_evaluation_and_compensation',
'WC1Q24_06': 'trustworthy_management',
'WC1Q25_01': 'encouraging_change_and_innovation',
'WC1Q25_02': 'rewarding_innovation',
'WC1Q25_03': 'favoring_creativity_over_diligence',
'WC1Q25_04': 'family_like_atmosphere',
'WC1Q25_05': 'emphasis_on_unity',
'WC1Q25_06': 'emphasis_on_teamwork',
'WC1Q25_07': 'emphasis_on_formal_procedures',
'WC1Q25_08': 'top_down_communication',
'WC1Q25_09': 'emphasis_on_hierarchy',
'WC1Q25_10': 'emphasis_on_competition_and_performance',
'WC1Q25_11': 'emphasis_on_expertise_and_ability',
'WC1Q25_12': 'performance_based_evaluation',
'WC1Q26_01': 'satisfaction_with_job_content',
'WC1Q26_02': 'satisfaction_with_salary',
'WC1Q26_03': 'satisfaction_with_relationships',
'WC1Q26_04': 'overall_job_satisfaction',
'WC1Q27_01': 'considering_leaving_for_better_conditions',
'WC1Q27_02': 'identifying_with_company_problems',
'WC1Q27_03': 'losing_much_if_leaving_company',
'WC1Q27_04': 'company_deserving_loyalty',
'WC1Q27_05': 'unfair_development_and_promotion_opportunities',
'WC1Q27_06': 'feeling_helpless_or_tired',
'WC1Q27_07': 'increased_job_tension',
'WC1DQ01': 'gender',
'WC1DQ02_01': 'birth_year',
'WC1DQ02_02': 'birth_month',
'WC1DQ03': 'marital_status',
'WC1DQ04': 'education_level',
'WC1DQ04_01': 'major'
})
# 관련 있는 변수들의 평균 계산
df['hr_role_avg'] = df[['contribution_to_strategy', 'influence_on_decision_making', 'role_in_hr_improvement', 'leading_change_and_innovation']].mean(axis=1)
df['hr_trust_avg'] = df[['educating_managers', 'explaining_hr_policies', 'trusted_by_employees', 'expertise_in_field']].mean(axis=1)
df['training_avg'] = df[['sufficient_training', 'equal_training_opportunities', 'desire_for_training', 'job_relevance_of_training', 'applicability_of_training', 'versatility_of_training']].mean(axis=1)
df['informal_learning_avg'] = df[['peer_coaching_mentoring', 'supervisor_coaching_mentoring', 'knowledge_sharing_among_employees', 'knowledge_sharing_through_platform', 'learning_through_job_rotation']].mean(axis=1)
df['self_directed_learning_avg'] = df[['support_for_academy_tuition', 'support_for_domestic_university_tuition', 'support_for_domestic_graduate_school_tuition', 'support_for_overseas_graduate_degree']].mean(axis=1)
df['organizational_characteristics_avg'] = df[['active_problem_solving', 'diverse_experience_opportunities', 'autonomy_in_work', 'cooperation_and_trust', 'diverse_competencies_and_experience', 'good_communication']].mean(axis=1)
df['management_emphasis_avg'] = df[['preferential_treatment_of_talent', 'clear_vision_for_hr_development', 'emphasis_on_talent', 'diverse_training_methods']].mean(axis=1)
df['organizational_communication_avg'] = df[['informing_employees', 'freedom_to_express_opinions', 'interdepartmental_communication', 'trust_among_colleagues', 'fair_evaluation_and_compensation', 'trustworthy_management']].mean(axis=1)
df['organizational_culture_avg'] = df[['encouraging_change_and_innovation', 'rewarding_innovation', 'favoring_creativity_over_diligence', 'family_like_atmosphere', 'emphasis_on_unity', 'emphasis_on_teamwork', 'emphasis_on_formal_procedures', 'top_down_communication', 'emphasis_on_hierarchy', 'emphasis_on_competition_and_performance', 'emphasis_on_expertise_and_ability', 'performance_based_evaluation']].mean(axis=1)
df['job_satisfaction_avg'] = df[['satisfaction_with_job_content', 'satisfaction_with_salary', 'satisfaction_with_relationships', 'overall_job_satisfaction']].mean(axis=1)
df['organizational_commitment_avg'] = df[['considering_leaving_for_better_conditions', 'identifying_with_company_problems', 'losing_much_if_leaving_company', 'company_deserving_loyalty', 'unfair_development_and_promotion_opportunities', 'feeling_helpless_or_tired', 'increased_job_tension']].mean(axis=1)
# 새로운 데이터프레임 저장
df.to_excel('ChatGPT_Sample_Data_Encoded_0518_processed.xlsx', index=False)