- [Instructor] Next, let's continue the session
that we started in the preceding video
and in particular, let's continue to learn about our data
by looking at some simple data analysis.
So first of all, let's go ahead
and execute a titanic dot describe method call.
Now before I hit Enter, notice again,
we have five columns of data, however,
when I described the titanic data set,
I only get one column of output
and the reason for that is by default,
the described method looks for columns
that contain numeric data and only calculates
these descriptive statistics on the numeric columns.
In a moment, I'll take a look at a non numeric column
and we'll do some descriptive statistics on that as well.
So for the titanic's age column,
first of all, I want you to notice
that it only counted 1,046 records.
Now, if you look up here, you can see
that that the highest numbered record was 1,308
and the first one was zero so there's 1,309 records
in this data set or rows in this data frame,
yet it only counted 1,046 in the age column
because some of the ages are missing.
So we see one missing value for the age here
represented is not a number and in pandas,
when you describe a column by default,
it ignores the missing data.
So it counted up only the rows of the data set
that actually had an age value
and there were 1,046 of those.
For those 1,046 people, we can see
that the average age was close to 30,
we can see that the minimum age
was only point one seven years,
which works out to a little over two months,
we can see that the maximum age was 80
and remember that the quartile values,
50% quartile represents the median of the sorted age values.
So the median age was 28, the median age
for the first half of the folks who had age values was 21
and the median age for the last half
of the folks who had age values was 39.
So we can see some basic descriptive
statistics for the age here.
Now let's assume for a moment that we'd like
to know some information about
how many people survived versus did not survive.
So we can actually figure that out
by selecting from the data frame,
a series that checks whether each person survived or not.
So let's go ahead and copy another
snippet in here and we'll paste it in.
So we're going to first execute
this parenthesized expression,
which uses the numpy style capability
of broadcasting to compare every single survived value
in the survived column with the value Yes,
and the result is going to be true or false.
I will get back as a result of this highlighted expression,
a series of true, false values where everyone
that compared equal to yes will be true
and everyone that did not compare
equal to yes will be false.
Those that are true are the folks who survived,
those that are false are the folks who died.
Now I can call describe on that series,
which is non numeric, by the way
and it will give me some other
descriptive statistics for that non numeric data.
We still get account so we see 1,309 here,
which means every single record had a yes
or no value for that survived column.
We can see that there's only two unique values
in that column, in this case, true,
they survived or false, they did not.
And we can see that the top value was false,
the most frequently occurring value was false
and that occurred 809 times
so 809 people died and the other
500 passengers survived the disaster.