1
00:00:00,570 --> 00:00:03,770
Alright, now you know how to extract potion of a data frame.

2
00:00:03,900 --> 00:00:08,580
But how about deleting columns or rows so from the data frame?

3
00:00:08,670 --> 00:00:16,610
Well for that you'd want to use the df7.drop, so the drop method.

4
00:00:16,680 --> 00:00:22,350
Note that this is also not an in place operation so your df7 data frame will not be updated

5
00:00:22,350 --> 00:00:27,550
with the deleted column and yeah, let me delete the city column.

6
00:00:27,630 --> 00:00:32,830
You'd pass city for the column name and then one and so one.

7
00:00:32,830 --> 00:00:36,090
The one argument me that you were about to delete columns.

8
00:00:36,090 --> 00:00:38,520
That's all you tell pandas or Python

9
00:00:38,580 --> 00:00:42,390
what you're about to delete. When you delete rows you want to pass zero there.

10
00:00:43,860 --> 00:00:45,590
So yeah.

11
00:00:45,690 --> 00:00:49,880
This is the on the fly data frame without the city column there.

12
00:00:49,920 --> 00:00:58,020
So again the df7 with city and drop.

13
00:00:58,050 --> 00:01:01,480
Let me drop "332 HillSt".

14
00:01:01,910 --> 00:01:04,990
Zero.

15
00:01:05,610 --> 00:01:05,960
Yeah.

16
00:01:06,000 --> 00:01:07,470
Hill street is not there.

17
00:01:09,780 --> 00:01:14,900
And of course if you want to update your data frame with the changes you do that.

18
00:01:15,000 --> 00:01:22,110
Then when you print out your df7 data frame, the Hill street is not there.

19
00:01:22,200 --> 00:01:32,490
Yeah if you want to drop columns so rows based on indexing you do a trick like df7 and then point

20
00:01:32,490 --> 00:01:34,800
to index and then what do you want.

21
00:01:35,130 --> 00:01:36,650
Well 0 to 3 maybe.

22
00:01:37,590 --> 00:01:44,390
So you're deleting rows. Execute that, and you get the three rows only.

23
00:01:44,730 --> 00:01:52,560
Similarly with columns. Columns and one in here.

24
00:01:53,300 --> 00:01:57,210
So you get ID, name, and state, the first three columns.

25
00:01:57,210 --> 00:02:04,790
So if that's confused, you know df7 dot index the one that gives you is is a series with

26
00:02:04,790 --> 00:02:07,710
the names, so with the labels of your index column.

27
00:02:07,710 --> 00:02:15,960
So all these, and similarly columns give you the names of your columns.

28
00:02:16,110 --> 00:02:17,540
So that's how you access

29
00:02:17,570 --> 00:02:21,670
the header of your data frame and the index column.

30
00:02:21,970 --> 00:02:25,750
And yeah, that was about deleting columns and rows from a data frame.

31
00:02:26,040 --> 00:02:28,660
If you have questions just feel free to ask them.

32
00:02:28,670 --> 00:02:29,460
And I'll talk to you

33
00:02:29,460 --> 00:02:30,180
in the next lecture.

