WEBVTT

00:00.810 --> 00:06.840
In this video we learn how to use the methods and unique and largest and smallest for complete data

00:06.840 --> 00:08.100
frame.

00:08.090 --> 00:14.760
So first of all let's import pandas and we work with the Titanic data set and we will have a look at

00:14.760 --> 00:16.100
the first five rows.

00:16.110 --> 00:20.810
And the last five rows and four pandas serious.

00:20.840 --> 00:28.890
That is the method unique and let's try out if that's also the method unique for a complete data frame

00:30.240 --> 00:31.770
and we get here an error message.

00:31.770 --> 00:39.370
So data frame object has no attributes unique so no panacea is the unique method actually returns say

00:39.460 --> 00:41.280
umpire Ray with all unique value.

00:41.290 --> 00:43.810
So let's try this for The Age column

00:49.320 --> 00:53.010
so we give we get to the unique values for the age column.

00:53.010 --> 01:00.070
However the end unique method also works for a complete data frame and let's try this out here.

01:00.570 --> 01:07.450
And obviously for each column here we get the amount of unique values in the column.

01:07.620 --> 01:11.060
For example as far survived we have 1 0 0 0.

01:11.060 --> 01:14.250
So we have two unique values for passenger class.

01:14.250 --> 01:15.830
We have three unique values.

01:15.840 --> 01:20.130
So Class 1 2 and 3 4 6 we have 2 unique values.

01:20.130 --> 01:22.110
Male and female and so on

01:24.900 --> 01:33.220
and let's have a tech here with the shift tab so we have further parameters axis and drop and a so by

01:33.220 --> 01:37.200
default we drop all missing values but we can change this here

01:41.860 --> 01:47.280
and there I can see in the columns that we have missing values the number of unique values increased

01:47.280 --> 01:51.570
by 1 so by the missing value by the end a value.

01:51.570 --> 01:56.940
And now you can see here that we have for each column the unique values but we can also decide here

01:57.300 --> 02:03.000
that we want to have for each row the unique values by putting your X's equals 1

02:06.550 --> 02:12.320
and in our case of a third the Titanic said I said that's not too meaningful here in row 1 we have 8

02:12.340 --> 02:24.160
unique values so let's check this so we have 1 2 3 4 5 we already had 0 6 7 and 8 including the missing

02:24.160 --> 02:27.320
value will we have 8 unique values.

02:27.320 --> 02:36.880
All right and again we can either include or exclude the missing values here.

02:37.020 --> 02:43.250
Okay so now let's try the method and largest which we also have for pandas serious and let's try to

02:43.250 --> 02:51.050
apply this also for a complete data frame and that's press shift tap here and largest that returns the

02:51.050 --> 02:54.790
first and Rose ordered by columns in the descending order.

02:55.550 --> 03:02.840
So we have to pass here and which stands for example for five rows or four ten rows.

03:03.080 --> 03:08.540
And we have to define the columns by which you want to order a data frame so for example we want to

03:08.540 --> 03:14.000
have the five passengers who paid the largest fare or the largest ticket price.

03:14.150 --> 03:21.010
So let's try this out here and here we have peasants on number 2 5 8.

03:21.100 --> 03:28.930
And uh she paid actually five hundred and twelve dollars a pound and then we have passengers six hundred

03:28.940 --> 03:29.850
seventy nine.

03:30.430 --> 03:36.430
And he also paid five hundred and twelve and the peasants are paid.

03:36.480 --> 03:40.170
The fifth largest ticket price is passenger number eighty eight.

03:40.170 --> 03:46.860
And he paid two hundred and sixty three dollars or pounds and he would actually get the same result

03:47.150 --> 03:53.790
with the software use so we could sort our data frame by the fare column in a descending manner and

03:53.790 --> 03:57.880
then get to the first five rows and this method.

03:57.930 --> 04:04.090
So that's the same here and that's also the end smallest method.

04:04.090 --> 04:09.950
It also works with the complete data frame and with the end smallest method we could filter actually

04:09.950 --> 04:12.520
the five fare youngest passengers on board.

04:12.560 --> 04:20.910
So let's try this so and here we have the five youngest passengers so we have passenger number 800 and

04:20.910 --> 04:24.620
the three And he's only open 40 years old.

04:24.620 --> 04:29.070
And and the fifth the youngest passengers passenger numbers 78.

04:29.250 --> 04:36.610
And he is 0 point eight three years old and we can also change end to one so we can only select the

04:36.610 --> 04:39.330
youngest passenger here.

04:39.910 --> 04:42.990
And as you can see here we get here still a data frame.

04:43.000 --> 04:47.430
So we have a data frame with one row so passenger number 8 0 3.

04:47.740 --> 04:56.880
And before we also learned that we can filter out a specific row with the method idea X-Men so here

04:56.970 --> 05:03.600
is the age column we get the index label for the youngest passenger and then we filled out the row of

05:03.780 --> 05:06.450
the youngest peasant service then the log operator.

05:06.450 --> 05:13.680
And here we do not get a data frame but we get to hear a panda series so on the left we have the columns

05:13.680 --> 05:21.380
and on the right the values and we have a set and smallest we still get a data frame here with only

05:21.380 --> 05:24.300
one row and the values here.

05:24.540 --> 05:24.950
All right.

05:24.950 --> 05:29.390
So now we are finished with this video and I hope to see you in the next one by.
