Exploration
You may make plots regularly, but in this course, it is important that you can explicitly control which axis different time series are plotted on. This will be important so you can evaluate your time series predictions later.
Here your task is to plot a dataset of monthly US candy production between 1972 and 2018.
Specifically, you are plotting the industrial production index IPG3113N. This is total amount of sugar and confectionery products produced in the USA per month, as a percentage of the January 2012 production. So 120 would be 120% of the January 2012 industrial production.
Check out how this quantity has changed over time and how it changes throughout the year.
This exercise is part of the course
ARIMA Models in Python
Exercise instructions
- Import
matplotlib.pyplot
giving it the aliasplt
and importpandas
giving it the aliaspd
. - Load in the candy production time series
'candy_production.csv'
usingpandas
, set the index to the'date'
column, parse the dates and assign it to the variablecandy
. - Plot the time series onto the axis
ax1
using the DataFrame's.plot()
method. Then show the plot.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import modules
import ____ as ____
import ____ as ____
# Load in the time series
candy = pd.____('candy_production.csv',
____='____',
____=____)
# Plot and show the time series on axis ax1
fig, ax1 = plt.subplots()
____.____(ax=____)
____