為相關性擷取特徵
在這個練習中,你將使用包含新欄位 "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()