1 00:00:00,000 --> 00:00:02,129 All right, now you know how to extract 2 00:00:02,130 --> 00:00:04,440 portion of a dataframe. But how about 3 00:00:04,440 --> 00:00:07,788 deleting columns or rows from the DataFrame? 4 00:00:08,267 --> 00:00:12,210 Well, for that, you'd want to use 5 00:00:12,935 --> 00:00:16,805 df7.drop, so the drop method, know 6 00:00:16,830 --> 00:00:18,900 that this is also not an inplace 7 00:00:18,900 --> 00:00:21,120 operation. So your df7 DataFrame 8 00:00:21,120 --> 00:00:24,030 will not be updated with the deleted column. 9 00:00:24,608 --> 00:00:26,340 And here let me delete the City 10 00:00:26,340 --> 00:00:29,490 column. You'd pass City for the column 11 00:00:29,490 --> 00:00:33,180 name, and then 1, and so 1 12 00:00:33,180 --> 00:00:34,860 argument means that you are about to 13 00:00:34,860 --> 00:00:37,200 delete columns. That's how you tell 14 00:00:37,230 --> 00:00:39,330 Pandas or Python, what you're about to 15 00:00:39,330 --> 00:00:41,190 delete, or when you delete rows, you 16 00:00:41,190 --> 00:00:45,840 want to pass a 0 there. So and yeah, this 17 00:00:45,840 --> 00:00:48,570 is the on the fly DataFrame with 18 00:00:48,570 --> 00:00:51,994 all the City column there. So again, df7 19 00:00:52,047 --> 00:00:58,350 with City and drop, let me 20 00:00:58,350 --> 00:01:04,155 drop 332 Hill St, 0 21 00:01:05,328 --> 00:01:07,470 and yeah, Hill Street is not there. 22 00:01:07,494 --> 00:01:09,665 [No audio] 23 00:01:09,690 --> 00:01:11,400 And of course, if you want to update 24 00:01:11,400 --> 00:01:13,650 your DataFrame with the changes you 25 00:01:13,650 --> 00:01:19,203 do that, then when you print out your df7 26 00:01:19,228 --> 00:01:21,030 DataFrame, the Hill Street 27 00:01:21,030 --> 00:01:25,260 not there, and yeah, if you want to drop 28 00:01:25,260 --> 00:01:29,490 columns or rows based on indexing, you 29 00:01:29,490 --> 00:01:32,430 do a trick like df7 and then points 30 00:01:32,455 --> 00:01:34,825 to index, and then what do you want? 31 00:01:35,026 --> 00:01:38,866 Well, 0 to 3 maybe. So you're deleting 32 00:01:39,480 --> 00:01:43,530 rows, execute that, and you gather three 33 00:01:43,530 --> 00:01:47,471 rows only. Similarly with columns, columns 34 00:01:49,144 --> 00:01:50,745 and 1 in here. 35 00:01:50,770 --> 00:01:53,165 [No audio] 36 00:01:53,190 --> 00:01:54,515 So you get ID, Name, 37 00:01:54,540 --> 00:01:57,630 and State, the first three columns. So if 38 00:01:57,630 --> 00:02:00,986 that confused you, you know, df7.index, 39 00:02:01,011 --> 00:02:02,672 what that gives you is a 40 00:02:02,697 --> 00:02:06,420 series with a name so with the labels of 41 00:02:06,420 --> 00:02:09,630 your index column, so all this, and 42 00:02:09,630 --> 00:02:14,675 similarly, columns gives you the names of 43 00:02:14,700 --> 00:02:17,220 your columns. So that's how you access 44 00:02:17,220 --> 00:02:19,110 the, your, the header of your DataFrame, 45 00:02:19,533 --> 00:02:22,923 and the index column. Yeah, that was about 46 00:02:22,950 --> 00:02:25,790 deleting columns and rows from DataFrame. 47 00:02:25,912 --> 00:02:27,240 If you have questions, just feel 48 00:02:27,240 --> 00:02:29,400 free to ask them, and I'll talk to you 49 00:02:29,400 --> 00:02:30,906 in the next lecture.