Session Ready
Exercise

Renaming Columns

See how easy that was? You tidied up your dataset with a single command! Now we just need a bit more fine-tuning. Change the column names with pandas' rename function. Its syntax is df.rename(columns = d, inplace = False), where d is a dictionary where the keys are the columns you want to change, and the values are the new names for these columns. The code inplace = False means the result would be stored in a new DataFrame instead of the original one.

Instructions
100 XP
  • Rename the variable column of df2_melted to Year and the value column to Income.
  • Click "Submit Answer" to print out the new tidy DataFrame.