Ipython Presentation

List of tutorials, etc...:


In [1]:
import fred
import numpy as np
import pandas as pd

In [2]:
api_key = 'insert your key here'

fred.key(api_key)


Out[2]:
<fred.core.Fred at 0x7faec46ee9e8>

In [3]:
#fred.search("Income")

In [4]:
gdp = fred.observations("GDP")
#gdp

In [5]:
#put the data in a dataframe
data = pd.DataFrame(gdp['observations'])
#data


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-5-70945a9d9b18> in <module>()
      1 #put the data in a dataframe
----> 2 data = pd.DataFrame(gdp['observations'])
      3 #data

KeyError: 'observations'

In [ ]:
# fix missing
data['value'] = data['value'].replace('.', np.NaN)
data = data.dropna()
data['value'] = data['value'].astype(float)

# dates
dates = pd.Series(pd.to_datetime(data['date']))

# plotting
import matplotlib.pyplot as plt
plt.plot_date(dates, data['value'])
plt.show()

In [1]:
import matplotlib.pyplot as plt
plt.clf()

x = np.arange(0,5,0.1)
y = np.sin(x)
plt.plot(x,y)
plt.show()