Importing data from fred

Hi, i would like to import from this web site the shiller index about the real estate usa.

i am tring using this code but does not working. 

Could you help me?





url = "S&P CoreLogic Case-Shiller U.S. National Home Price Index | ALFRED | St. Louis Fed

request = urllib.request.Request(url)

response = urllib.request.urlopen(request)

print (response.read().decode('utf-8'))



error 

NameError: name 'urllib' is not defined

also the data from this link are monthly and i am using also daily data from yahoo finance. 
so there will be a very big different in the total number of row of difference 
between one and one other. 
how can i resolve this problem?

i would like to compare the sma of the real estate with the sma closing price of one stock 
usa. 

thanks. 


Hi Irene,



The error is due to a missing import statement. You can put "import urllib" at the top of your code to resolve the same. 

Also, for the second issue, you can try resampling the daily data into monthly data, finding the SMA for monthly data and then comparing them. You can refer to this link to learn more about resampling.



Hope this helps!



Thanks,

Akshay