เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Create a new column

In the last exercise, you converted the column plane_year to an integer. This column holds the year each plane was manufactured. However, your model will use the planes' age, which is slightly different from the year it was made!

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Foundations of PySpark

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Create the column plane_age using the .withColumn() method and subtracting the year of manufacture (column plane_year) from the year (column year) of the flight.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Create the column plane_age
model_data = model_data.withColumn("plane_age", ____.____ - ____.____)
แก้ไขและรันโค้ด