CommencerCommencer gratuitement

Correlations between multiple time series

In the previous exercise, you extracted the seasonal component of each time series in the jobs DataFrame and stored those results in new DataFrame called seasonality_df. In the context of jobs data, it can be interesting to compare seasonality behavior, as this may help uncover which job industries are the most similar or the most different.

This can be achieved by using the seasonality_df DataFrame and computing the correlation between each time series in the dataset. In this exercise, you will leverage what you have learned in Chapter 4 to compute and create a clustermap visualization of the correlations between time series in the seasonality_df DataFrame.

Cet exercice fait partie du cours

Visualizing Time Series Data in Python

Afficher le cours

Instructions

  • Compute the correlation between all columns in the seasonality_df DataFrame using the spearman method and assign the results to seasonality_corr.
  • Create a new clustermap of your correlation matrix.
  • Print the correlation value between the seasonalities of the Government and Education & Health industries.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Get correlation matrix of the seasonality_df DataFrame
seasonality_corr = ____

# Customize the clustermap of the seasonality_corr correlation matrix
fig = ____(____, annot=True, annot_kws={"size": 4}, linewidths=.4, figsize=(15, 10))
plt.setp(fig.ax_heatmap.yaxis.get_majorticklabels(), rotation=0)
plt.setp(fig.ax_heatmap.xaxis.get_majorticklabels(), rotation=90)
plt.show()

# Print the correlation between the seasonalities of the Government and Education & Health industries
print(____)
Modifier et exécuter le code