LoslegenKostenlos loslegen

Compute correlations between time series

The correlation coefficient can be used to determine how multiple variables (or a group of time series) are associated with one another. The result is a correlation matrix that describes the correlation between time series. Note that the diagonal values in a correlation matrix will always be 1, since a time series will always be perfectly correlated with itself.

Correlation coefficients can be computed with the pearson, kendall and spearman methods. A full discussion of these different methods is outside the scope of this course, but the pearson method should be used when relationships between your variables are thought to be linear, while the kendall and spearman methods should be used when relationships between your variables are thought to be non-linear.

Diese Übung ist Teil des Kurses

Visualizing Time Series Data in Python

Kurs anzeigen

Interaktive Übung

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

# Compute the correlation between the beef and pork columns using the spearman method
print(meat[['beef', 'pork']].corr(method=____))

# Print the correlation between beef and pork columns
print(____)
Code bearbeiten und ausführen