- To finish up our discussion of
the Titanic data set for now,
we'd like to take a look at how we can visualize
a little bit of this data,
and for that purpose,
we're going to take advantage of a built in
Pandas capability for displaying a histogram
based on specifically the age column in this case.
So in order to do that,
we need to enable Matplotlib support.
Pandas uses Matplotlib to implement its graphics.
We're in a curin IPython session in which I did not
enable Matplotlib support as I launched the session,
so here we want to talk about using
the magic called Matplotlib.
And what Matplotlib,
I'm just making sure I spelled it correctly here.
And that's going to enable Matplotlib support
in the current session,
so even if you didn't launch Ipython with Matplotlib support
you can enable it after the fact by using this magic.
So now that we have that set up,
we can go ahead and create a histogram,
and to do that, we'll use a very simple method
call hist stands for histogram,
and when you invoke that on a data frame,
it's going to create histograms for
all of the numeric columns by default.
So there's only one,
which means it's only going to create one histogram,
and in this case we'll hit enter and let that
create the histogram
which will pop open in a separate window here.
And now what you see is a histogram
of everything created for you auto-magically, if you will.
On the left hand column,
we have the number of passengers in a given age range,
and down along the bottom we have the age ranges.
So you can see this first block here
represents what looks like about zero through eight or so,
so there were somewhere around maybe 70 people
who were in the zero to eight range.
In this next block here,
maybe we had about 60 people
who were in the eight to approximately 16 or 17 range.
In this next block here,
we had over 250 people, maybe 275 or so,
280 people that were in approximately
the 17 to maybe 24 range, et cetera,
so you can see we get this kind of contiguous presentation
of ranges of values and
the number of people inside those ranges.
So, again, this is a key aspect of
getting to know your data,
to visualize that data,
and sometimes by looking at it in a picture,
you can understand the data a little bit better as well.
So we will of course do lots of visualizations
in subsequent examples and we just wanted to give you
a basic demonstration here,
and of course, Pandas has other visualization capabilities
above and beyond simple histograms
that we're showing in this example.