WEBVTT

00:01.170 --> 00:02.070
Hi everyone.

00:02.070 --> 00:08.070
So in this video we learn how to select rose and that the special index operator a log which enables

00:08.070 --> 00:10.880
us to slow court position based indexing.

00:11.190 --> 00:17.130
But before we introduce a brand new data frame that contains all metals that have been awarded an Olympic

00:17.130 --> 00:22.010
summer games from eighteen hundred ninety six to 2012.

00:22.080 --> 00:25.820
So in our photo that's already start a CSP fight.

00:25.830 --> 00:27.930
Call it some adopt see a suite.

00:28.560 --> 00:35.630
And we can impart to So first of all we have to import pandas and then we can import our summer dot

00:35.730 --> 00:37.370
see a sweet file with them.

00:37.380 --> 00:46.740
The pandas method read C a we and we assign the variable summer and we can f look at our data frame.

00:46.740 --> 00:53.330
So here are the first five rows and actually each row is actually a medal that the has been awarded

00:53.440 --> 00:56.100
during a summer Olympic games.

00:56.220 --> 01:01.530
So it's starting here from eighteen hundred ninety six and the host city was Athens.

01:01.540 --> 01:09.950
Um the sport was aquatics discipline swimming and the athlete that won the gold medal was afraid hails

01:10.410 --> 01:17.190
from Hungary and it's a man and the event was hundred meter freestyle swimming.

01:17.400 --> 01:18.110
So let's check.

01:18.120 --> 01:21.830
Also the last five rows with them the Taylor method

01:26.200 --> 01:35.470
so we end here in the year 2012 where the host city was London and the very last medal that was awarded

01:35.860 --> 01:38.260
was in wrestling freestyle.

01:39.220 --> 01:43.030
And the athlete was Jimmy Lindbergh from Sweden.

01:43.030 --> 01:51.120
It's a man obviously and the event was wrestling freestyle until the 96 kg and he won the bronze medal

01:52.410 --> 01:58.730
and let's also get some meta information so let's call the method info

02:01.850 --> 02:08.550
and here we can see we have a range indexed so here the indexed Labor starts from zero to thirty one

02:08.550 --> 02:10.670
thousand one hundred sixty four.

02:10.710 --> 02:14.550
So we have thirty one thousand one hundred sixty five entries are rows.

02:14.580 --> 02:20.760
So in total thirty one thousand one hundred sixty five medals were awarded.

02:20.760 --> 02:23.480
And our data frame contains some nine columns.

02:23.760 --> 02:29.750
So yes it is part disciplined athlete country gender event and medal Yeah.

02:29.790 --> 02:34.490
And actually we have almost no missing values only in the country column.

02:34.500 --> 02:42.250
We have actually four missing values and the data types are in the year column in the US and in all

02:42.270 --> 02:45.540
the other columns mustering so he is object.

02:45.570 --> 02:46.480
But an easy read.

02:46.490 --> 02:54.410
So if we see object here we have actually a string data type in the columns and we have already a memory

02:54.410 --> 02:56.750
use itself off to point to one megabyte.

02:56.750 --> 03:03.500
So this is actually a larger data set than the Titanic data set.

03:03.500 --> 03:09.260
All right so now we want to select a single rose and let's assume we want to select only here the very

03:09.260 --> 03:20.480
first row of tiles and let's type summer and in the last video we saw that by just passing here the

03:20.510 --> 03:28.920
LEI the 0 does not work and therefore we have to introduce and our indexing operator I log so we write

03:28.940 --> 03:37.000
here dot I log and so then in step brackets we pass in the index position of the row that we want to

03:37.000 --> 03:37.480
select.

03:37.480 --> 03:41.910
So you want to select select the very first row here.

03:41.910 --> 03:46.310
And the concept of zero based indexing also works with a log.

03:46.330 --> 03:52.490
So if you want to select the very first row we have to select the row at indexed positions 0.

03:53.950 --> 04:01.640
So let's try it here and now we get the very first row and the values of the very first row are here

04:01.640 --> 04:05.800
on the right side and the column labels on the left side.

04:05.960 --> 04:14.630
So we have the 896 in the city Athens the spot was aquatics that discipline while swimming the athlete

04:14.660 --> 04:18.620
was afraid hails from Hungary.

04:18.680 --> 04:25.850
He's a man and the event was a hundred meter freestyle and he won the gold medal and we can also check

04:26.000 --> 04:28.220
the data type off our slides here

04:35.890 --> 04:39.500
and same as with columns if you slice one row with and the eye look.

04:39.510 --> 04:46.550
Operator we get a panda serious and we can also select other rows so let's copy it here.

04:46.900 --> 04:56.230
So let's select the second draw at index position 1 and we get here auto hash man who won the silver

04:56.230 --> 04:56.610
medal.

04:56.640 --> 04:58.330
Let's check it here.

04:58.380 --> 05:07.030
Here that the second draw at an exposition 1 or two a man so and same as with the lists a number higher

05:07.030 --> 05:11.650
raise them the zero based indexing works and also we can index

05:14.590 --> 05:18.520
the very last row by having the index position minus one

05:21.270 --> 05:28.670
so here we get the very last row it's here to me left back so also here we get the pen the serious with

05:28.810 --> 05:29.870
the very last throw.

05:29.870 --> 05:38.840
So to me that back won bronze and say yes to that lists an umpire race that can also make slices.

05:38.840 --> 05:46.320
So for example we want to have uh the first five rows so starting from an next position 0 2 indicate

05:46.340 --> 05:51.590
position five but five excluding Sonia.

05:51.590 --> 06:02.060
We get to the very first five rows and of course we can also get the very last five rows so starting

06:02.060 --> 06:05.200
from the next position minus five.

06:05.200 --> 06:06.800
To the very last

06:09.480 --> 06:14.730
and this would give us them the same five last rows and then the tail method so starting from Damion

06:14.760 --> 06:21.510
Jankowski to Jimmy Lynn back here we have the tail method Exactly

06:24.610 --> 06:24.780
yeah.

06:24.790 --> 06:31.910
And we can also make some way advance slices so let's say we want to have the rolls from index position

06:32.890 --> 06:39.240
456 till index position four hundred fifty nine.

06:39.370 --> 06:43.130
So here we have some medals from nineteen hundred and Paris.

06:43.270 --> 06:50.990
And this plus rowing and what we can also do we can pass a list of index positions.

06:51.130 --> 06:52.450
So for example

06:55.350 --> 07:02.050
we want to have the robot in next position to at an exposition forty five and that next position seven

07:02.050 --> 07:09.430
hundred sixty five so we pass here a list of index positions within our span brackets here

07:12.540 --> 07:18.770
and here we get the rows at an exposition to forty five and seven hundred sixty five all right so on

07:18.770 --> 07:23.720
this video we learned how to slice and select rows with the eye lock operator.

07:23.730 --> 07:31.310
And essentially it works them the exact same way as slicing it lists or an umpire race with them position

07:31.310 --> 07:32.510
based indexing.

07:32.510 --> 07:34.380
So this is actually nothing new.

07:34.380 --> 07:39.530
And in the next session we learn how to slice rows and columns of the the I log.

07:39.710 --> 07:40.820
So hope to see you there.

07:40.870 --> 07:41.090
By.
