Understand the idea
Correlation summarizes how two numeric measurements move together along a straight-line pattern.
A small example
If x increases as y increases, correlation is positive. If y decreases instead, it is negative.
Follow the code
Apply the idea to the supplied table. Read from top to bottom; the final line displays the result.
df.corr(numeric_only=True)What each part does
df.corr(numeric_only=True)- correlations among numeric columns
numeric_only=True- leave text columns out
diagonal- a varying column correlates 1 with itself
Your inputs
The editable setup on the right creates df. Run executes the setup and your work from top to bottom.
| student | club | hours | score | group |
|---|---|---|---|---|
| Ari | Art | 1 | 52 | A |
| Bo | Code | 3 | 71 | A |
| Cy | Art | 2 | 65 | B |
| Dee | Code | 4 | 82 | B |
| Eli | Art | 5 | 89 | A |
| Flo | Code | 3 | 76 | A |
| Gus | Art | 6 | 93 | B |
| Han | Code | 2 | 61 | B |
Your task · Follow
Using df, return the correlation matrix for all numeric columns in Study club.
Hint
Select numeric measurements and remember that a matrix reports pairwise linear associations.
Reveal solution
One way to do it. Keep any supplied setup in the editor and use this in the Your work section.
df.corr(numeric_only=True)