1. Learn
  2. /
  3. Courses
  4. /
  5. Manipulating Time Series Data in Python

Connected

Exercise

Use interpolation to create weekly employment data

You have recently used the civilian US unemployment rate, and converted it from monthly to weekly frequency using simple forward or backfill methods.

Compare your previous approach to the new .interpolate() method that you learned about in this video.

Instructions

100 XP

We have imported pandas as pd and matplotlib.pyplot as plt for you. We have also loaded the monthly unemployment rate from 2010 to 2016 into a variable monthly.

  • Inspect monthly using .info().
  • Create a pd.date_range() with weekly dates, using the .min() and .max() of the index of monthly as start and end, respectively, and assign the result to weekly_dates.
  • Apply .reindex() using weekly_dates to monthly and assign the output to weekly.
  • Create new columns 'ffill' and 'interpolated' by applying .ffill() and .interpolate() to weekly.UNRATE.
  • Show a plot of weekly.