Skip to content

Instantly share code, notes, and snippets.

@trcook
Created March 17, 2017 19:13
Show Gist options
  • Save trcook/7c77e69299679a72d779e5841ddd202e to your computer and use it in GitHub Desktop.
Save trcook/7c77e69299679a72d779e5841ddd202e to your computer and use it in GitHub Desktop.
random scrap to get and plot series from fred
import fredapi as fred
import pandas
import matplotlib.pyplot as plt
apikey=open("/Users/j1trc01/.fred_api_key",'r').read()
Fred=fred.Fred(apikey)
gdpnow=Fred.get_series("GDPNOW")
gdp=Fred.get_series("A191RL1Q225SBEA")
dat=pd.DataFrame({'gdpnow':gdpnow,'gdp':gdp})
dat['error']=abs(dat['gdpnow']-dat['gdp'])
plt.plot(dat.error,c='r')
plt.show()
msk=dat.gdpnow.isnull()==False
plt.plot(dat.gdp[msk],label='gdp')
plt.plot(dat.gdpnow[msk],label='gdpnow')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment