WEBVTT

00:00.810 --> 00:07.470
In this video we learn how to remove complete columns from a data frame and falsify the import pandas

00:08.160 --> 00:10.590
and import our Summer Olympic Games.

00:10.650 --> 00:11.610
Metadata friend

00:14.460 --> 00:17.210
and have a look at the first five rows.

00:17.760 --> 00:24.350
And here we can see that we have the columns that sparked discipline and we went and let us assume we

00:24.350 --> 00:26.390
only want to keep the column event.

00:26.420 --> 00:32.260
Because then the information in the spot column and disciplined column are a bit redundant actually

00:34.660 --> 00:42.580
so first of all we tried to remove the spot column and therefore we can use them the drop method and

00:42.580 --> 00:43.540
then the drop method.

00:43.540 --> 00:50.440
We can pass the label off the column we want to remove to the parameter columns and let's see what we

00:50.440 --> 00:53.750
get here.

00:53.830 --> 00:56.830
We get here a data frame without them these sports column

01:05.810 --> 01:11.490
All right so let's check again our data frame and here we can see that the sponsor column is still in

01:11.490 --> 01:18.930
our data frame so also the drop method has the in-place parameter of it's us by default set to false

01:19.440 --> 01:24.930
and if you want to change our data frame we have to set them the in-place parameter to true.

01:25.200 --> 01:31.200
But before we said we want to drop them the sports column and the discipline column and we can of course

01:31.230 --> 01:39.500
also remove multiple columns within the drop method and we can do this by passing a list of column labels

01:39.500 --> 01:42.000
to the parameter columns.

01:42.440 --> 01:43.460
So let's check here

01:46.740 --> 01:51.220
so here we can see that we remove the column sport in the column discipline.

01:51.220 --> 01:56.660
And now if you want to make this in place and change our rates or data frame we have to set that the

01:56.660 --> 02:02.030
in-place parameter to true and let's check again our data frame

02:05.190 --> 02:12.590
and now we can see that now in our data frame there is no sport and no discipline column and let's assume

02:12.590 --> 02:17.740
we want to drop also the event column then we again use the drop method.

02:17.960 --> 02:25.580
But instead of passing the event column to the parameter column we can also pass event to the parameter

02:25.580 --> 02:27.380
label so let's check here.

02:27.410 --> 02:33.080
So before we passed along our columns that we wanted to drop to the perimeter columns but we can also

02:33.080 --> 02:39.560
pass them this to labels and define the access from which we want to drop our label.

02:39.560 --> 02:49.700
And in this case it's either we can use 1 4 columns so let's secure now where we have removed the event

02:49.750 --> 02:57.910
or we can use in quotation marks columns and is missing here

03:01.590 --> 03:03.420
so that's actually the second alternative.

03:03.420 --> 03:10.200
So either we pass our column labels to the pyramid columns we posit to the perimeter labels and define

03:10.260 --> 03:17.050
the axis as columns or as one and again we have to separate the in-place parameter to true

03:22.210 --> 03:26.420
and second again our data frame.

03:26.430 --> 03:33.480
So now we have removed uh the spots column the discipline column and the event column and that's another

03:33.720 --> 03:35.260
way to remove a column.

03:35.310 --> 03:40.910
This the keyboard delete and then selecting the event column from our summer data frame.

03:40.920 --> 03:42.800
But I wouldn't recommend this one.

03:42.800 --> 03:48.740
So I would definitely go for the top method here and use the drop method to drop a column.

03:49.800 --> 03:54.350
So now let's import our summers the data again.

03:54.510 --> 03:57.080
So this is the original one.

03:57.360 --> 04:04.350
And before we drop them the columns sport discipline and event but instead of dropping the two columns

04:04.380 --> 04:12.750
we could also explicitly select the other columns so we could select a year city athlete country gender

04:12.810 --> 04:16.170
and medal and we can do this service to the local operator.

04:17.120 --> 04:23.180
So we select all rows and then we pass a list of column labels that we want to keep in our summer data

04:23.180 --> 04:23.600
frame.

04:23.600 --> 04:32.200
So yes city athlete country gender and medal and we override our summers data frame so our new data

04:32.200 --> 04:39.460
frame summer data frame contains the column C a city athlete country tandem medal and it does not contain

04:39.490 --> 04:44.260
the columns sport discipline and event.

04:44.590 --> 04:51.040
All right so this also works and it depends actually on the case but then you drop in the column so

04:51.070 --> 04:54.370
that you don't need or you select the columns that you need.

04:54.370 --> 05:00.760
So let's assume we have a data frame with 100 columns and you want to drop one column then you should

05:00.760 --> 05:03.020
definitely use the drop method.

05:03.010 --> 05:08.830
But if you have a data frame with 100 columns and you want to keep only two columns then it makes more

05:08.830 --> 05:13.140
sense to explicitly select the two columns.

05:13.160 --> 05:17.540
All right so now we are finished with the session and I hope to see you in the next session by.
