LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Visualizing Time Series Data in Python

Kurs anzeigen

Anleitung zur Übung

  • Iterate through each column name in jobs_names and extract the corresponding seasonal component from jobs_decomp. Place the results in the jobs_seasonal, where the column name is the name of the time series, and the value is the seasonal component of the time series.
  • Convert jobs_seasonal to a DataFrame and call it seasonality_df.
  • Create a facetted plot of all 16 columns in seasonality_df. Ensure that the subgraphs do not share y-axis.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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()
Code bearbeiten und ausführen