Class 1: Two examples

Two introductory examples to get the course started

Example 1: Hello world


In [1]:
# Print the character string `hello world`
print('Hello world!')


Hello world!

Example 2: Make a plot of the US unemployment rate

Download data from FRED (https://fred.stlouisfed.org/) and make a well-labeled plot


In [2]:
# Import the series function from fredpy
from fredpy import series

# Import the plotting library matplotlib.pyplot as plt
import matplotlib.pyplot as plt

# Specify that you want plots displayed in the Jupyter Notebook and not in an external window
%matplotlib inline

# Download the unemployment data from 
unemployment = series('unrate')

# Create a plot of the unemployment rate
plt.plot_date(unemployment.dates,unemployment.data,'-',lw=3,alpha = 0.6)
plt.ylabel('Percent')
plt.title('US Unemployment Rate')
plt.grid()

# Save the figure to the current working directory at 120 dots per inch resolution
plt.savefig('fig.png',dpi=120)