WEBVTT

00:00.480 --> 00:01.410
Hi everybody.

00:01.770 --> 00:07.410
So in this video we learn how to select rows with suspect brackets in the same way as the last.

00:07.410 --> 00:10.760
The lesson we learned how to select the columns as Bap.

00:10.770 --> 00:14.130
However by selecting arrows is back brackets them.

00:14.130 --> 00:15.680
This is actually not advisable.

00:15.710 --> 00:22.200
And I show you in this lesson and the next lessons that there are better alternatives to do this.

00:22.200 --> 00:26.130
How about pen does this the complex topic and far for many tasks.

00:26.190 --> 00:32.580
There are many ways to do it and in most cases and there are good ways to do something and the very

00:32.580 --> 00:36.730
best ways to do something that are also dangerous and can lead to mistakes.

00:36.730 --> 00:43.620
So with large data sets this hundred thousands of millions of rows you even do not get a read that you

00:43.620 --> 00:47.940
have done something wrong or something which was actually not your intention.

00:48.060 --> 00:53.700
And I think it's also important to show you the pitfalls and make you about potential problems in order

00:53.700 --> 00:57.480
to prevent you from making mistakes that are actually not necessary.

00:58.410 --> 01:05.640
So first of all as always let's import peanuts and we import our Titanic data set and we check in the

01:05.640 --> 01:11.980
first rows and now we assume we want to select them only the very first peasants are here with them.

01:11.990 --> 01:24.310
The row labeled 0 and in the same way as with columns we just try to select our first row here by passing

01:24.340 --> 01:31.290
our row label 0 within this brackets and let's see what we get here and we get an error message.

01:31.300 --> 01:40.620
Key arrow 0 so actually paste and does not know if you want to select a row or column and it searches

01:40.710 --> 01:42.370
for the column labeled 0.

01:42.390 --> 01:49.140
And that is actually no column with the column labeled 0 and consequently passing the drops us here

01:49.140 --> 01:57.010
an error message but what we can do here actually we can make a trick and slice from 0 to 1 and let's

01:57.010 --> 01:57.930
see what we get here.

01:57.940 --> 02:02.550
So we get here the first peasant service them index labeled 0.

02:02.800 --> 02:08.830
And yeah actually this works in the same mass slicing a list or an umpire Ray now so so-called position

02:08.830 --> 02:09.730
based slicing.

02:09.740 --> 02:16.060
So the starting point is including and the ending point is excluding so we are slicing our data frame

02:16.510 --> 02:17.840
from the index label.

02:17.850 --> 02:28.830
0 intuiting onto the index label 1 excluding and this way we can make different slices here so we can

02:28.830 --> 02:29.660
also slice.

02:29.670 --> 02:33.180
Let's say from 3 to 5.

02:33.600 --> 02:39.990
So we would expect to have their overs index label 3 and 4 and excluding 5.

02:40.050 --> 02:40.730
That's correct.

02:41.930 --> 02:48.530
And we can also slice for the very first 10 rows here

02:52.320 --> 02:57.980
so the very first 10 rows excluding the rovers index label 10.

02:58.080 --> 03:05.610
So we get here from 0 to 9 and this is actually the same as having here the head method

03:12.150 --> 03:13.080
and applying 10.

03:13.080 --> 03:15.480
So give me the first 10 rows.

03:15.630 --> 03:22.630
So from 0 to 9 and of course we can also slice

03:25.930 --> 03:39.210
the very last 10 rows so it can slice from minus 10 to the very last row so you can see in the last

03:39.210 --> 03:47.010
10 rows and as before applying the tail method with an equals 10 would give us and the same results

03:48.600 --> 03:53.630
so this was a quick overview of our slicing rows with the spat brackets.

03:53.640 --> 03:57.110
And as I said before this is not a good way to do it.

03:57.120 --> 04:00.410
So we will see in the next lessons how to do it in the correct way.

04:00.410 --> 04:01.770
So I hope to see you there by.
