Get startedGet started for free

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.

This exercise is part of the course

Joining Data with pandas

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Use merge_ordered() to merge gdp and sp500 on year and date
gdp_sp500 = pd.merge_ordered(____, ____, left_on=____, right_on=____, 
                             how=____)

# Print gdp_sp500
print(____)
Edit and Run Code