Hello, and welcome to a video on correlation matrices in Python. Let's use the ADD data again.
So, as usual, we're going to be importing pandas as PD, and from Google Colab we'll import drive, so that
we can mount our drive, set our file path, and read in our data through that file path.
Okay, so you can see, for the ADD data set, we have some new variables
that we get to work with. We have GPA, social probability, dropout rates, IQ,
ADDSC, which is some score related to psychology, but I wouldn't
know off the top of my head what it is. Let's say we'd like to know the correlations
between ADDSC, GPA, and IQ. The code to do this is fairly straightforward. So first, let's
subset our data. We'll create a subset data frame, equal to DF,
and it's important to have these two braces here when you're subsetting. This lets Python know we would
like just these variables from this data set. We want ADDSC, GPA,
and IQ. Next, we'll make our correlation matrix. So, I've made a variable called
correlation matrix. That is equal to subset, DF, dot, core.
This is something that's available through regular Python. So, we don't have to import any special libraries to do it. Next, we'll
print our correlation matrix. And that's it. We can see we have a positive
correlation between GPA and IQ and negative correlations between all the the rest of them.
All right, that's all we have to say about correlation matrices. Happy coding!