Я хотел бы создать корреляцию с одной переменной в качестве независимой и несколькими дополнительными переменными в качестве зависимой, а затем превратить ее в тепловую карту.
Я следую этим указаниям .
Мой код:
df_corr_interest = df[df.columns[0:11]].corr()['impact_action_yn'][:-1]
#set fig size
fig, ax = plt.subplots(figsize=(20,15))
#plot matrix
sns.heatmap(df_corr_interest, square=True,annot=True, annot_kws={'size':12},cmap="GnBu")
plt.show();
Я получаю следующую ошибку: KeyError: 'impact_action_yn'
Кадр данных:
ExternalReference interest_el interest_pl interest_ad interest_ol commitment_elected commitment_policy commitment_advocacy commitment_organizing timeline_elected ... Policy Organizing Engagement Parent Veteran first_gen_american first_gen_college ri_region LGBTQ Gender
0 0034000001RHCU0AAP 1 1 1 1 0 0 0 0 0 ... 0 0 1 0 0 0 0 0 0 Woman
1 00340000015yDbOAAU 1 1 1 2 0 0 0 2 0 ... 0 1 2 0 0 0 0 1 0 Man
2 0034000000y3QjMAAU 1 2 2 2 0 2 3 4 0 ... 5 2 3 0 0 0 0 1 0 Man
3 0034000001qcNXRAA2 1 1 1 3 0 0 0 3 0 ... 0 1 6 0 0 0 0 1 0 Woman
4 0034000001DVPedAAH 1 1 1 1 0 0 0 0 0 ... 0 0 1 0 0 0 0 0 0 Woman
Мысли?
Обновлено с полным списком переменных:
ExternalReference object
interest_el int64
interest_pl int64
interest_ad int64
interest_ol int64
commitment_elected int64
commitment_policy int64
commitment_advocacy int64
commitment_organizing int64
timeline_elected int64
timeline_policy int64
timeline_advocacy int64
timeline_organizing int64
interest_appointed float64
interest_vol_organizing float64
interest_school_organizing float64
impact_action_yn float64
impact_action_public_action float64
impact_action_testified float64
impact_action_met_el float64
impact_action_lobbied float64
impact_action_bill float64
impact_action_other float64
impact_action_other_text object
impact_topic_charter_schools float64
impact_topics_ece float64
impact_topics_postsecondary float64
impact_topics_school_choice float64
impact_topics_student_achv float64
impact_topics_district_perf float64
impact_topics_wraparound float64
impact_topics_school_discipline float64
impact_topics_special_pops float64
impact_topics_teacher_tenure float64
impact_topics_other float64
impact_topics_other_text object
impact_role object
impact_level float64
impact_level_text object
impact_success float64
impact_other_comments object
Advocacy int64
Elected int64
Policy int64
Organizing int64
Engagement int64
Parent int64
Veteran int64
first_gen_american int64
first_gen_college int64
ri_region int64
LGBTQ int64
Gender object
dtype: object