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.
Este ejercicio forma parte del curso
Visualizing Time Series Data in Python
Instrucciones del ejercicio
- Iterate through each column name in
jobs_namesand extract the correspondingseasonalcomponent fromjobs_decomp. Place the results in thejobs_seasonal, where the column name is the name of the time series, and the value is theseasonalcomponent of the time series. - Convert
jobs_seasonalto 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.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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()