Visualize the seasonality of multiple time series
You will now extract the seasonality
component of jobs_decomp
to visualize the seasonality in these time series. Note that before plotting, you will have to convert the dictionary of seasonality
components into a DataFrame using the pd.DataFrame.from_dict()
function.
An empty dictionary jobs_seasonal
and the time series decomposition object jobs_decomp
from the previous exercise are available in your workspace.
This exercise is part of the course
Visualizing Time Series Data in Python
Exercise instructions
- Iterate through each column name in
jobs_names
and extract the correspondingseasonal
component fromjobs_decomp
. Place the results in thejobs_seasonal
, where the column name is the name of the time series, and the value is theseasonal
component of the time series. - Convert
jobs_seasonal
to a DataFrame and call itseasonality_df
. - Create a facetted plot of all 16 columns in
seasonality_df
. Ensure that the subgraphs do not share y-axis.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Extract the seasonal values for the decomposition of each time series
for ts in ____:
jobs_seasonal[ts] = jobs_decomp[ts]____
# Create a DataFrame from the jobs_seasonal dictionary
____ = ____(jobs_seasonal)
# Remove the label for the index
seasonality_df.index.name = None
# Create a faceted plot of the seasonality_df DataFrame
____(subplots=____,
layout=____,
sharey=____,
fontsize=2,
linewidth=0.3,
legend=False)
# Show plot
plt.show()