1. 학습
  2. /
  3. 강의
  4. /
  5. Foundations of PySpark

Connected

연습 문제

String to integer

Now you'll use the .cast() method you learned in the previous exercise to convert all the appropriate columns from your DataFrame model_data to integers!

To convert the type of a column using the .cast() method, you can write code like this:

dataframe = dataframe.withColumn("col", dataframe.col.cast("new_type"))

지침

100 XP
  • Use the method .withColumn() to .cast() the following columns to type "integer". Access the columns using the df.col notation:
    • model_data.arr_delay
    • model_data.air_time
    • model_data.month
    • model_data.plane_year