因子关系与分布

Python 中的探索性数据分析

Izzy Weber

Curriculum Manager, DataCamp

教育水平:男性伴侣

divorce["education_man"].value_counts()
Professional    1313
Preparatory      501
Secondary        288
Primary          100
None               4
Other              3
Name: education_man, dtype: int64
Python 中的探索性数据分析

探索分类关系

sns.histplot(data=divorce, x="marriage_duration", binwidth=1)
plt.show()

婚姻持续时间的直方图

Python 中的探索性数据分析

探索分类关系

sns.histplot(data=divorce, x="marriage_duration", hue="education_man", binwidth=1)
plt.show()

婚姻持续时间直方图,按 education_man 着色

Python 中的探索性数据分析

核密度估计(KDE)图

sns.kdeplot(data=divorce, x="marriage_duration", hue="education_man")
plt.show()

婚姻持续时间的KDE,按education_man着色

Python 中的探索性数据分析

核密度估计(KDE)图

婚姻持续时间的KDE,按education_man着色,放大到 marriage_duration 为 0

Python 中的探索性数据分析

核密度估计(KDE)图

sns.kdeplot(data=divorce, x="marriage_duration", hue="education_man", cut=0)
plt.show()

婚姻持续时间的KDE,按education_man着色,cut为0

Python 中的探索性数据分析

累积KDE图

sns.kdeplot(data=divorce, x="marriage_duration", hue="education_man", cut=0, cumulative=True)
plt.show()

婚姻持续时间的累积分布函数,按education_man着色,cut为0

Python 中的探索性数据分析

结婚年龄与教育的关系

  • 结婚年龄与受教育程度是否相关?
divorce["man_age_marriage"] = divorce["marriage_year"] - divorce["dob_man"].dt.year
divorce["woman_age_marriage"] = divorce["marriage_year"] - divorce["dob_woman"].dt.year
Python 中的探索性数据分析

含分类变量的散点图

sns.scatterplot(data=divorce, x="woman_age_marriage", y="man_age_marriage")
plt.show()

woman_age_marriage 与 man_age_marriage 的散点图

Python 中的探索性数据分析

含分类变量的散点图

sns.scatterplot(data=divorce, 
                x="woman_age_marriage",
                y="man_age_marriage", 
                hue="education_man")
plt.show()

woman_age_marriage 与 man_age_marriage 的散点图,按 education_man 着色

Python 中的探索性数据分析

开始练习吧!

Python 中的探索性数据分析

Preparing Video For Download...