ฟีเจอร์จากข้อมูลวันที่
อีกหนึ่งงาน feature engineering ที่ต้องทำคือการดึงค่าเดือนและปี ให้ดำเนินการนี้กับคอลัมน์ date ในชุดข้อมูล ufo
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การเตรียมข้อมูลสำหรับ Machine Learning ด้วย Python
คำแนะนำการฝึกหัด
- แสดง
.head()ของคอลัมน์date - ดึงค่า attribute เดือนจากคอลัมน์
date - ดึงค่า attribute ปีจากคอลัมน์
date - ดู
.head()ของคอลัมน์date,month, และyear
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# 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(____)