WEBVTT

00:00.970 --> 00:07.180
Hi everybody is so in this video we learn how to select rows with the index operator loke the so-called

00:07.210 --> 00:13.420
label based indexing and we will see in a minute but the differences to position based indexing with

00:13.540 --> 00:14.370
the eye log.

00:14.370 --> 00:16.420
OPERATOR So what.

00:16.420 --> 00:23.200
First of all we import pandas as always and we import our Summer Olympic Games data frame and we have

00:23.200 --> 00:29.680
a look at the first five rows and before we can select so let's assume we want to select the third row

00:29.680 --> 00:36.610
at the next position to this Dimitrios device so we can take summer thought I'd like.

00:37.510 --> 00:40.700
And then the next position too.

00:41.170 --> 00:45.870
And here we get a panda serious with the athlete the Dimitrios three of us.

00:45.930 --> 00:52.810
Won bronze in the 100 meter freestyle for sailors and the method read CSP provides many options and

00:52.810 --> 00:57.270
parameters to customize our imparting of CSP files.

00:57.280 --> 01:02.860
So on by default to the row index is a range indexed starting from zero but they are we can change this

01:02.950 --> 01:09.640
and we can determine yet each of our column and our data frame as the index column or the index.

01:09.640 --> 01:17.530
So that is the parameter index column and that we can pass a column of our data frame and determine

01:17.800 --> 01:20.040
the column s of the index of our data frame.

01:20.050 --> 01:22.420
So let's try for example athlete

01:27.230 --> 01:28.640
and let's have a check here.

01:28.640 --> 01:36.920
So now we can see that the athlete column is actually now our index off our data frame and the eye log

01:36.950 --> 01:39.380
operator still works also with a different index.

01:39.380 --> 01:42.280
So not only with the range index.

01:42.500 --> 01:48.560
So what the island operator does it simply selects in the row at the index position to for example and

01:48.680 --> 01:56.440
this is irrespective of which column we selected here as the index so let's check here again and we

01:56.440 --> 02:00.240
still get here the rovers the Dimitrios three of us.

02:00.340 --> 02:05.410
So that's no difference for the island operator if you change here the index labels.

02:05.410 --> 02:11.080
However there are some minor differences so the athlete label itself is not yet on the left side as

02:11.190 --> 02:14.920
the index label off our pandas series which we created here.

02:15.010 --> 02:17.890
And actually the whole name of our pandas seriousness.

02:17.920 --> 02:20.920
Um yeah actually DiMaggio's three of us.

02:21.070 --> 02:21.480
All right.

02:21.490 --> 02:29.740
So now let's head over to the loke operator and now we still want to select that row of Dimitrios three

02:29.740 --> 02:36.280
of us and what we have to do here we have to pass that then this back brackets the index label in this

02:36.280 --> 02:41.840
case Dimitrios three of us in quotation marks

02:46.160 --> 02:52.630
and again we get a panda serious with them the row of Dimitrios three US was so years cities Park discipline

02:52.640 --> 03:00.200
country gender event and medal as labels on the left side and the values on the right side and the whole

03:00.200 --> 03:03.170
pandas serious is called Dimitrios to leave us.

03:03.260 --> 03:09.560
All right so let's search for a very famous sports stars and we could search for Michael Phelps for

03:09.560 --> 03:10.190
example.

03:11.570 --> 03:13.700
So we have to pass in quotation marks.

03:13.730 --> 03:18.450
The name here and capital letters so helps comma.

03:18.590 --> 03:22.640
And then the first name where only the first characters and capital letters.

03:22.640 --> 03:23.660
So Michael

03:27.060 --> 03:28.230
now yes a typo.

03:28.390 --> 03:31.780
So it's my car now.

03:34.090 --> 03:35.050
No.

03:35.240 --> 03:42.320
And instead of getting only one row as a pen serious we get to hear a complete pen that stayed off frame

03:42.420 --> 03:45.100
because my good friend says one how many medals.

03:45.110 --> 03:48.220
And he appeared in the index many times.

03:48.290 --> 03:55.190
So if you select the index label Michael Phelps listed the loke operator then we get all appearances

03:55.200 --> 04:00.780
of the index label Michael Phelps and now what.

04:00.780 --> 04:07.500
If you want to select only the very first medal then we can do this by slicing the very first throw

04:07.500 --> 04:15.540
here off our new data frame by applying the I luck operator and selecting the very fast draw at an exposition

04:15.560 --> 04:16.330
zero.

04:16.380 --> 04:23.970
So I would expect that we get the gold medal from 2004 for the 100 meter butterfly event

04:26.740 --> 04:27.730
and is this correct.

04:27.730 --> 04:33.450
So now we have a pen a serious and this is actually the pitfall of the log operator.

04:33.510 --> 04:35.940
So if you have duplicates in our index.

04:35.940 --> 04:41.700
So Michael Phelps has many appearances then logo returns as a data frame.

04:41.700 --> 04:47.710
And if you have only one appearance of the labor for which we want to slice our data frame for example

04:47.720 --> 04:51.060
here Dimitrios through us we get a pan that serious.

04:51.060 --> 04:57.510
So far the same operation we get as a return different data types and that's always a bit difficult

04:57.600 --> 05:01.260
because of the functionality is different.

05:01.280 --> 05:01.660
All right.

05:01.670 --> 05:06.140
So now we are finished with this session and in the next session we will have a look at the slicing

05:06.140 --> 05:07.910
rows and columns.

05:08.050 --> 05:09.120
The low operate.

05:09.160 --> 05:10.610
So hope to see you there by.
