1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to PySpark

Connected

Exercise

Column operations - creating and renaming columns

The census dataset is still not quite showing everything you want it to. Let's make a new synthetic column by adding a new column based on existing columns, and rename it for clarity.

Remember, there's already a SparkSession called spark in your workspace!

Instructions

100 XP
  • Create a new column, "weekly_salary", by dividing the "income" column by 52.
  • Rename the "age" column to "years".
  • Show the resulting DataFrame.