因子の関係と分布

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()

Histogram of marriage duration

Pythonによる探索的データ分析

カテゴリ変数との関係を探る

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

Histogram of marriage duration color coded by education_man

Pythonによる探索的データ分析

カーネル密度推定(KDE)プロット

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

marriage duration kde with hue set to education_man

Pythonによる探索的データ分析

カーネル密度推定(KDE)プロット

marriage duration kde with hue set to educationman, zoomed in to marriageduration of zero

Pythonによる探索的データ分析

カーネル密度推定(KDE)プロット

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

marriage duration kde with hue set to education_man and cut equal to zero

Pythonによる探索的データ分析

累積KDEプロット

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

marriage duration cumulative distribution function with hue set to education_man and cut equal to zero

Pythonによる探索的データ分析

結婚時年齢と教育レベルの関係

  • 結婚時年齢と教育レベルに関係はありますか?`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()

A scatterplot of woman_age_marriage and man_age_marriage

Pythonによる探索的データ分析

カテゴリ変数を使った散布図

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

A scatterplot of woman_age_marriage and man_age_marriage with hue set to education_man

Pythonによる探索的データ分析

練習してみましょう!

Pythonによる探索的データ分析

Preparing Video For Download...