相関分析のための特徴量の抽出
この演習では、"date_of_response" という新しい列を含む salaries データセットを使います。
このデータセットはpandasのDataFrameとして読み込まれており、"date_of_response" は datetime 型になっています。
この列からdatetime属性を抽出し、変数間の相関係数を可視化するヒートマップを作成します。
Seaborn は sns、として、 pandas は pd として、matplotlib.pyplot は plt としてインポート済みです。
この演習はコースの一部です
Pythonによる探索的データ分析
演習の手順
"date_of_response"から月を抽出し、"month"という列に格納してください。- 参加者がアンケートに回答した曜日を格納する
"weekday"列を作成してください。 - ピアソンの相関係数を表示したヒートマップを作成してください。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Get the month of the response
salaries["month"] = ____["____"].____.____
# Extract the weekday of the response
salaries["weekday"] = ____
# Create a heatmap
sns.____(____.____(numeric_only=True), annot=____)
plt.show()