WEBVTT

00:01.030 --> 00:01.870
Hi everyone.

00:01.870 --> 00:07.270
So in the last few days we learned how to index then select a rose from a panda's data frame with the

00:07.270 --> 00:08.210
index operator.

00:08.230 --> 00:15.600
I log and in this video we will index not only rose but also columns for the eye look operator.

00:16.150 --> 00:23.830
But first of all we import pandas and we import our Summer Olympic Games medal data set and we have

00:23.830 --> 00:25.560
a look at the first five throws.

00:25.570 --> 00:27.940
So no surprise here.

00:27.940 --> 00:34.650
And what we already learned we can for example select the very first row at an exposition zero.

00:34.740 --> 00:41.460
It's uh the I like operator by passing here.

00:41.470 --> 00:43.620
The index positions zero.

00:45.010 --> 00:46.840
And we get here as a panda.

00:46.840 --> 00:51.340
Serious the first row off our pandas data frame.

00:51.430 --> 00:56.430
Now let's assume we only want to have the name of the athlete off to the first draw.

00:56.490 --> 00:59.480
Then we can in addition slice also for the athlete.

00:59.790 --> 01:01.190
So we make a comment here.

01:01.350 --> 01:06.590
So the first position within the brackets here is for the index position of our rows.

01:06.600 --> 01:11.580
And the second position here is for the index positions of our columns.

01:11.580 --> 01:12.530
We want to select.

01:12.990 --> 01:16.170
So here we want to select the athlete column.

01:16.320 --> 01:18.840
And we have to apply position based indexing.

01:18.900 --> 01:22.110
Same mess with lists an umpire race and matrices.

01:22.110 --> 01:32.820
So our year column has them the index positions 0 1 2 3 and our athlete column has them the index position

01:32.820 --> 01:33.240
far

01:37.500 --> 01:43.840
and TV get them the athlete of the very first the medal and it's I say tiles.

01:43.870 --> 01:45.790
So now what if you want to select.

01:45.820 --> 01:50.910
For the first row the columns yes city and sport.

01:51.250 --> 01:54.790
So let's copy and paste it.

01:54.880 --> 02:00.700
So we want to slice for the column at an exposition 0 1 and 2.

02:01.210 --> 02:10.150
So the therapist next thing we have to slice from index position zero and to index position of three

02:10.150 --> 02:13.860
excluding song.

02:13.860 --> 02:15.140
Here we get the the year.

02:15.150 --> 02:21.100
The city in the sports column for our very first row is on its nineteen hundred ninety six and Essence

02:21.120 --> 02:24.590
and its Aquatics and this the I operator.

02:24.690 --> 02:29.760
It works out exactly in the same way as selecting and slicing and umpire race.

02:30.210 --> 02:35.610
So the first position is for the row and next position and the second position is for the column and

02:35.610 --> 02:38.750
next position and zero indexing applies as well.

02:38.760 --> 02:46.320
And if we slice the starting points including and the ending points excluding and we can also pass a

02:46.320 --> 02:46.850
list.

02:46.920 --> 02:54.520
So let's copy and paste here and let's say we want again the first row but we want to have column at

02:54.520 --> 02:58.620
an exposition to 4 6 and 8.

02:58.660 --> 03:06.810
So let's see what we get here so the climate in exposition to a sport its aquatics column at an exposition

03:06.810 --> 03:14.220
for its athlete I feel it highlights the climate in exposition 6 is gender.

03:14.250 --> 03:22.410
So is a man and the column at an exposition 8 some kind of medal it's the gold medal and we can also

03:22.470 --> 03:27.010
make some more complex queries so there is no limit on this.

03:27.060 --> 03:35.010
So for example we want to have the column C a two four six and eight but we want to have the rows from

03:35.010 --> 03:44.030
in the exposition 34 including until next position let's say thirty nine excluding and here we can see

03:44.090 --> 03:51.480
we get the column sport athlete gender and medal farther rows from an exposition 34 until thirty eight

03:51.540 --> 03:55.540
including and with the I Look operator.

03:55.660 --> 04:01.200
We can also select the columns or complete columns so let's check it here.

04:01.250 --> 04:09.440
Some method I log and we can say we want for all rows we want to have column four here.

04:09.700 --> 04:18.280
So we get to a column form which is athlete and now we can check if this is the same as selecting a

04:18.280 --> 04:20.530
column with the attribute athlete.

04:21.130 --> 04:31.810
So we ask if some other I log all rows and the fourth column is equal to slam method athlete and that's

04:31.810 --> 04:39.710
true and we already learned that we can alternatively also slice for the athlete column by having athlete

04:39.890 --> 04:41.560
in brackets after summer.

04:41.570 --> 04:42.830
So that's also possible.

04:42.890 --> 04:44.570
So we are fierce free alternatives.

04:45.320 --> 04:49.720
However if I only want to slice for a column I would never use the i log.

04:50.030 --> 04:53.300
So some other athletes are smarter and better actually.

04:53.300 --> 04:59.870
All right so let's again slice here with the spare brackets to have it complete.

05:00.800 --> 05:03.140
So that's the third alternative.

05:03.140 --> 05:09.470
And with this we are finished now with the session and in the next session we will burn the index operator

05:09.470 --> 05:09.920
lock.

05:09.950 --> 05:11.570
So I hope to see you there by.
