1 00:00:00,720 --> 00:00:05,040 Hello, guys, and welcome back to another class of our course about the complete introduction to that 2 00:00:05,040 --> 00:00:05,460 assigns. 3 00:00:05,970 --> 00:00:12,130 So in this class, we are still talking about pendas operations and we are going to learn a basic pande 4 00:00:12,150 --> 00:00:13,890 operation that is called slicing. 5 00:00:14,700 --> 00:00:18,390 So be able to be able to explain to you what exactly is slicing. 6 00:00:18,810 --> 00:00:22,290 I'm going to present it by the use of this little database. 7 00:00:22,290 --> 00:00:27,810 So the database that we worked with a little bit before in this course, so pretty simple. 8 00:00:28,020 --> 00:00:31,020 Let's say you guys have your database right here. 9 00:00:31,020 --> 00:00:37,220 So you have your small database, but you only want the two first elements right there. 10 00:00:37,500 --> 00:00:44,220 So there is a way or there is a function that you guys can use with Banda's and Python to be able to 11 00:00:44,220 --> 00:00:51,090 only generate the two first rows, or if, for example, you want the tree, only the last word or only 12 00:00:51,090 --> 00:00:52,250 the four less rules. 13 00:00:52,530 --> 00:00:58,770 So basically there is an operation in Python that you guys can use to be able to only generate some 14 00:00:58,770 --> 00:01:03,360 rules, but not all the rules from your database. 15 00:01:03,570 --> 00:01:06,450 And this function is called head or tail. 16 00:01:07,360 --> 00:01:08,810 So you'll see it's pretty simple. 17 00:01:09,120 --> 00:01:14,940 So right here we have our database, as you can see, the exact same database that we wrote so we can 18 00:01:14,940 --> 00:01:18,900 write down table one right here to be able to run our database. 19 00:01:19,260 --> 00:01:21,710 So as you can see, we have our database that works perfectly. 20 00:01:22,170 --> 00:01:24,410 So what we want to do right now is pretty simple. 21 00:01:24,420 --> 00:01:29,310 So we're just going to add a little dot and we'll write down head. 22 00:01:29,970 --> 00:01:36,450 So what what we want right now, we want to generate the three first elements inside of this database. 23 00:01:36,460 --> 00:01:38,880 So basically we want to generate Abidjan and leave them. 24 00:01:39,720 --> 00:01:41,070 So how exactly will do this? 25 00:01:41,080 --> 00:01:41,640 Pretty simple. 26 00:01:41,640 --> 00:01:46,710 We just write down the head and then we enter the number of rows inside of the parenthesis. 27 00:01:46,720 --> 00:01:48,540 So let's say one, the three first rows. 28 00:01:48,550 --> 00:01:51,570 So in this case, it's going to be three and we run our up. 29 00:01:51,590 --> 00:01:55,410 So as you can see, we have the three first rows that have been generated. 30 00:01:55,710 --> 00:02:01,320 So we have about John and llena, if we only won the first row, so we'll do the exact same thing. 31 00:02:01,320 --> 00:02:04,830 So we'll just write down one so we'll only generate it. 32 00:02:05,510 --> 00:02:05,940 All right. 33 00:02:05,940 --> 00:02:12,570 So let's say right now we want to generate the last row, so we want to start generating from the employee 34 00:02:12,570 --> 00:02:13,330 number five. 35 00:02:13,890 --> 00:02:17,610 So in this case, we are going to use another function that is called tail. 36 00:02:18,000 --> 00:02:20,400 So we will write down the exact same thing. 37 00:02:20,400 --> 00:02:25,290 So we have our database will print our table, but we'll write down Dutil. 38 00:02:25,740 --> 00:02:28,220 And in this case, we want to generate which. 39 00:02:28,380 --> 00:02:30,270 So let's say we want to generate only the fifth row. 40 00:02:30,450 --> 00:02:32,940 So write down, tell and in the parenthesis. 41 00:02:32,970 --> 00:02:33,870 Right one. 42 00:02:34,920 --> 00:02:39,360 So basically, it's going to simply start calculating from the down. 43 00:02:39,390 --> 00:02:41,370 So from the letter, from the last one. 44 00:02:41,370 --> 00:02:46,550 So tail will start with learning from the last one and had we'll start calculating from the first one. 45 00:02:46,800 --> 00:02:52,380 So let's say we write down tail and we write down three is going to generate the three less. 46 00:02:52,380 --> 00:02:55,580 So in this case it's going to be llena, Mark and Bob. 47 00:02:56,340 --> 00:02:58,090 So I think you guys get the point. 48 00:02:58,110 --> 00:03:03,900 So basically, if you want to generate the first elements of your database, you simply use head. 49 00:03:04,410 --> 00:03:05,640 So let's try it out. 50 00:03:06,390 --> 00:03:09,300 We write down head and we run our up. 51 00:03:10,280 --> 00:03:16,520 And if we if you guys want to you to to generate the last elements of your radar base, it's going to 52 00:03:16,520 --> 00:03:17,220 be tail. 53 00:03:17,240 --> 00:03:20,540 So basically same thing, but just right down to it, you can run your app. 54 00:03:20,540 --> 00:03:24,490 And as you can see, it's going to generate the three last elements of your database. 55 00:03:24,970 --> 00:03:25,180 Right. 56 00:03:25,280 --> 00:03:26,150 So that's at first glance. 57 00:03:26,150 --> 00:03:30,740 Guys, I hope you have learned a new function of pandas as well as Biton. 58 00:03:31,490 --> 00:03:35,570 And see you all in our next class where we are still going to talk about pandas.