提取用于相关性的特征
在本练习中,您将使用包含新列 "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()