WEBVTT

00:00.670 --> 00:03.240
In this video we will have our first steps to this.

00:03.340 --> 00:08.280
The pandas index object and first of all it's in part the pandas.

00:09.040 --> 00:15.740
And we also impart our Summer Olympics medal status set and started in the area of the summer.

00:15.820 --> 00:26.820
And we have a look at the first five rows and the last five rows and we can call the info method to

00:26.820 --> 00:35.530
have a look at some meta data and we can call the attribute index and with the attribute index we can

00:35.530 --> 00:39.610
get information on our row index and the row index labels.

00:39.610 --> 00:47.100
Here we have a range index starting from zero to thirty one thousand one hundred sixty four.

00:47.270 --> 00:54.910
So we can also check the type of from the index here and it's a pandas index Range Index and we can

00:54.910 --> 01:00.760
do the same with the column so we can get additional information on our column in next in our column

01:00.760 --> 01:10.150
labels with the attribute columns so we can see here that it is a indexed object with the index labels

01:10.170 --> 01:20.370
or column labels and we can also check them the data type and it's the index object here and actually

01:20.370 --> 01:23.790
here it looks a bit like and then lists on the array.

01:24.120 --> 01:31.470
However compared to a list or an array the index object or index data type has special methods and attributes

01:31.590 --> 01:39.020
specifically designed for large datasets so with index objects you can do much more than for example

01:39.020 --> 01:39.600
over the list.

01:40.260 --> 01:45.210
And that's why developers of pandas created the index object to allow special index operations

01:48.390 --> 01:57.380
and with the attribute Xs we can have a look at both row index and column the next so we can see for

01:57.440 --> 02:02.570
the row we have arranged and next and the column index and say index this.

02:02.660 --> 02:09.920
The following labels here and we already learned that we can customize them the import with that they

02:09.920 --> 02:19.000
read CSP method and we can say that as index column we want to have for example the column athlete

02:22.230 --> 02:30.070
so now we have you on the left side and the athlete column SRO index and it's from here.

02:31.480 --> 02:34.020
And now if you call the index attribute

02:37.200 --> 02:40.420
we get here the new index with our index labels.

02:40.440 --> 02:49.820
So the athletes here and the type of the index is not a Range Index but an index with String objects.

02:49.830 --> 02:57.960
All right and also this index objects we can select and slide single and multiple elements of the index

02:57.960 --> 02:59.610
object.

02:59.680 --> 03:06.100
So for example if you want to slice the columns index for the first three elements you can slice from

03:06.100 --> 03:14.780
the very first element and the fourth element at index position three excluding So here we have the

03:14.780 --> 03:17.140
first three elements.

03:17.180 --> 03:25.200
So this is position based indexing with all the roots of zero base indexing and we can also select in

03:25.200 --> 03:29.790
the row index and the first element for example s for the tiles.

03:29.790 --> 03:38.960
And the last element would stimulate back and we can make slices from the one hundredths position until

03:38.960 --> 03:44.480
the 100 the second position excluding so I would expect to have two elements here.

03:44.510 --> 03:47.120
So we have Alfred FLATOW And Gustaf Felix.

03:47.120 --> 03:54.550
FLATOW So that's maybe brothers so before we accept that the index object tests specific methods and

03:54.550 --> 03:59.980
attributes that makes them so powerful but yeah actually it looks like a listen we can transform also

03:59.980 --> 04:05.390
a indexed object into a list with the method to list.

04:05.680 --> 04:12.190
So now before we head to the index object the column index object here is our elements and we saw here

04:12.220 --> 04:13.640
that it's indexed object.

04:13.660 --> 04:16.200
And here we have just in the list with the.

04:16.240 --> 04:23.410
Yes it is part discipline country agenda event and medal and before we learned that was the label based

04:23.440 --> 04:31.010
indexing it makes a difference if we have only unique values no index or if you have also duplicates.

04:31.010 --> 04:35.300
So if you selected Michael Phelps we got all occurrences in the data for a moment.

04:35.360 --> 04:42.170
If you only have unique values or labels in our index we get only single resides organized in the pattern

04:42.170 --> 04:43.550
of serious.

04:43.880 --> 04:45.890
And also this label best slicing.

04:45.890 --> 04:52.210
So for example if you slice for all rows from the beginning of our data frame until Michael Phelps it

04:52.220 --> 04:59.090
does not work because some slicing this duplicates does not work actually and that definitely makes

04:59.090 --> 05:05.600
sense to check our index if they are duplicates or if all labels are unique under this and the attribute

05:05.660 --> 05:15.020
is unique and here our summer index with our athletes we get a false and last but not least there is

05:15.070 --> 05:23.870
a another attribute called get luck and if you pass a index label to catalogue we get the position of

05:24.020 --> 05:29.070
the index label so let's try Dimitri all three of us and we get a two.

05:29.150 --> 05:34.190
So this is the next position too and we know that uh zero base and next thing applies so let's check

05:34.200 --> 05:34.430
it

05:39.710 --> 05:45.950
here we have our index object and that position is 0 we have 5 4 tiles at position 1 or 2 Ashman in

05:45.950 --> 05:51.790
that position to all 3 of us.

05:51.930 --> 05:52.370
All right.

05:52.380 --> 05:56.670
So now we are finished seventh this session and I hope to see you in the next session by.
