1. Learn
  2. /
  3. Courses
  4. /
  5. Joining Data with pandas

Connected

Exercise

Correlation between GDP and S&P500

In this exercise, you want to analyze stock returns from the S&P 500. You believe there may be a relationship between the returns of the S&P 500 and the GDP of the US. Merge the different datasets together to compute the correlation.

Two tables have been provided for you, named sp500, and gdp. As always, pandas has been imported for you as pd.

Instructions 1/3

undefined XP
    1
    2
    3
  • Use merge_ordered() to merge gdp and sp500 using a left join where the year column from gdp is matched with the date column from sp500.
  • Print gdp_sp500.