Session Ready
Exercise

Transforming variables

When variables have skewed distributions, they often require a transformation in order to form a linear relationship with another variable so that correlation can be computed. In this exercise, you'll perform a transformation yourself.

pandas as pd, numpy as np, matplotlib.pyplot as plt, and seaborn as sns are imported, and world_happiness is loaded.

Instructions 1/2
undefined XP
  • 1
    • Create a scatterplot of happiness_score versus gdp_per_cap and calculate the correlation between them.
    • 2
      • Add a new column to world_happiness called log_gdp_per_cap that contains the log of gdp_per_cap.
      • Create a seaborn scatterplot of log_gdp_per_cap and happiness_score and calculate the correlation between them.