从日期中构造特征
另一个需要进行的特征工程任务是提取"月"和"年"。请在 ufo 数据集的 date 列上完成该任务。
本练习是课程的一部分
Python 中的机器学习预处理
练习说明
- 打印
date列的.head()。 - 获取
date列的"月"属性。 - 获取
date列的"年"属性。 - 查看
date、month和year三列的.head()。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Look at the first 5 rows of the date column
print(____)
# Extract the month from the date column
ufo["month"] = ufo["date"].____
# Extract the year from the date column
ufo["year"] = ufo["date"].____
# Take a look at the head of all three columns
print(____)