Welcome back.
And so we've done a whole bunch of plotting so far.
And don't worry if you're sort of a little bit confused at the moment like here like Daniel showing
me all these plots I'm looking at different data sets.
How am I going to remember all this.
It's all right.
That's perfectly fine to feel like that it's going to take a little bit of practice to start to understand
different kinds of plots what you should use which plot for but that's all part of the process right
is just having a little practice having a go and just trying it out seeing what it looks like.
Does this make sense.
So that's why in this video we're going to do a similar plot to what we've just seen before on the car
sales data set on another data set.
Let's try on another dataset.
And if we come up here we've got heart disease dot CSB which we've seen before which is a data set which
has different parameters of patients and whether or not they have heart disease.
So let's import that as PD not read CSB as we're going to call it just heart disease and so we'll go.
Heart disease starts see as very beautiful.
Now we'll have a look at it just to make sure we know what's happening will only be the first five rows
because about 300 and this one excellent.
We have these parameters we've seen them before.
I've got a target column right on the end.
So what we might do is create a histogram just to see the distribution of the age column.
So heart disease age dot plot dot hist and we might just see the default number of beans.
Can you remember how many that will be shift tab.
Beans is going to be 10 beautiful so we'll just leave it at that OK.
So this is where we're starting to see that curve right.
This is that normal distribution.
It's very common so we're kind of getting that curve here.
We would say that most of the patients are around it's this line here so maybe late 50s early 60s thereabouts
and what if we changed the number of beans so let's go.
Beans equals 20 OK.
We're starting to lose that curve shape a little bit 30 still relatively there we're definitely starting
to see this more pronounced line here right at the late 50s there jacking up to 50 and see what happens.
All right so that shape is still relatively there our initial shape that what we got from just having
10 bends is kind of consistent the whole way through and maybe we'd look at this and go Okay this one's
a bit of an outlier.
These are a bit of an outlier.
Why are they outliers.
Well because they're so far from the middle.
When you hear the word outlier that's kind of what it's talking about in statistic terms.
It's about more than three standard deviations away from the mean.
Now of course that definition will change depending on what data are working with.
But this is kind of a way that you can visualize it.
So let's take that back to 10.
That looks pretty good.
All right.
Now these kind of visualizations are the things you'll do whenever you deal with a new data set.
Let's finish.
We have there's one more type of plot we haven't looked at directly from a data frame that's subplots.
So we'll finish that off.
We'll go to heart disease or head OK.
This is our data frame.
Now let's plot every single columns histogram in one plot.
Let's see how we would do that.
Heart disease.
So we've got the age histogram here.
But let's just make one for all of these and check the distribution dot plot haste.
So remember this is just going straight from the entire data frame up here we selected the age column
dot haste and maybe we want subplots equals true that makes sense because we want to put it all on the
one plot keyword arc.
So that's part of that.
Maybe if we could read down a little bit examples.
So this is one of those scenarios where if you wanted to use this dot his method and have it all on
one plot because the doc string doesn't really have an example of putting it all with the subplots.
This would take a little bit of research so you might look up a question like how to plot a histogram
on subplots from a panda's data frame and then you'd find this little parameter here.
Only reason I know it is because I've had a little bit of experience plotting subplots from Panda's
data frames.
So let's see what this looks like might take a little while because we're plotting 10 columns or 15
columns thereabouts.
All that doesn't look very good does it.
We're going to overlapping plots we've got legends everywhere we've got these things aren't even to
scale so maybe to fix it up we'll change the fig size.
So what do we want we want with height.
We want it to be a bit higher so it stretches it stretches it out because there's hardly any space here
OK.
That's looking a little bit better but still you've got columns like this which are just all clumped
up here because what it's doing is it's using the same scale for all of them but in reality these all
have different measures.
That's not very ideal right.
It might work out for some like this one cholesterol might work out for that column but it doesn't work
at all for the other ones right.
So slope I'll peak.
Exactly.
So what can we do.
Well this code runs but it's not ideal.
Then there's different scales and it's probably a bit too much going on for this plot to even be meaningful.
But this is a good segway though.
Now we've covered a few simple plots directly on a panda's data frame.
Let's have a look at how we'd make some visualizations using the O method.
So remember back in the previous video we talked about oh method which is subplots.
Don't worry if it's confusing we'll have a look in a second but what we've been using so far is plotting
directly from pandas using this stateless method.
So in the meantime I have a practice.
Keep using the plot.
Make another plot of your own.
Before we come into the next video and I'll see you there we'll practice using the more flexible object
orientated map plot named API directly with pandas.