WEBVTT

00:00.650 --> 00:05.290
In this video we learn how to change column labels of our data frame.

00:05.360 --> 00:12.200
So first of all let's import Parnassus always and we import our Titanic data set and we have a look

00:12.200 --> 00:16.010
at the first five rows and the last five rows.

00:16.730 --> 00:19.210
And then we can never look at our column labels.

00:19.220 --> 00:30.350
That's the attribute topped columns so it's survived PE class 6 8 cents on so same as here above and

00:30.350 --> 00:38.900
we can also index our column index object for example for the first element so the first element at

00:38.990 --> 00:42.150
index position 0 it's survived.

00:42.770 --> 00:46.060
And now let's assume that we are not happy with them the rod survived.

00:46.070 --> 00:48.760
So we would like to change it to a.

00:48.770 --> 00:57.350
For example and we can try to do so by setting a life as the new value so let's try this out.

00:57.560 --> 01:04.700
And here we get an error message index does not support mutable operations so same with row index objects.

01:04.700 --> 01:11.150
Also column index objects are immutable so we can only change them the whole index by passing a list

01:11.150 --> 01:13.450
or a sequence with new values.

01:13.490 --> 01:17.480
The tests are actually the same amount of elements in our index.

01:17.540 --> 01:24.100
So in our example here we have nine elements and we can pass a list with nine elements.

01:24.120 --> 01:28.410
So for example we can say that our column labels should be alive.

01:28.410 --> 01:31.530
Class 6 8 the S P.

01:31.590 --> 01:39.440
Parents and children fare embarked and tech so for each column label we pass here a new column label

01:41.260 --> 01:45.790
and let's try this out and let's have a look at the first five rows.

01:46.480 --> 01:50.390
So now we can see here we have changed all column labels so we have here.

01:50.770 --> 01:52.810
Class sex and so on.

01:54.300 --> 01:57.610
And we can also set a name for our column index object.

01:57.630 --> 01:59.400
So this that the attribute name.

02:00.300 --> 02:03.750
And so far we do not have a name for our index object.

02:03.750 --> 02:06.440
So we get nothing here but we can change some.

02:06.460 --> 02:15.440
This for example to a peasant like characteristics so now let's see again here and there can see here

02:15.930 --> 02:18.300
we have a name now for our column label.

02:18.300 --> 02:25.060
So these are the peasant characteristics and we can also set a name for our row and next.

02:25.090 --> 02:26.370
So let's try this out.

02:30.090 --> 02:36.570
So with the DOT index start name and so far we do not have a name that we can change this to.

02:36.570 --> 02:37.620
For example

02:40.320 --> 02:44.190
passenger numbers are starting from zero to eight hundred ninety one

02:49.020 --> 02:52.830
and let's check again here the first five rows.

02:52.880 --> 02:58.160
So now we have here a name for our column labels or passenger characteristics and we have a name for

02:58.160 --> 03:01.070
our row index passenger number.

03:01.070 --> 03:01.460
All right.

03:01.460 --> 03:07.450
So now in this video in the last video we learned how to change the complete row in next column index.

03:07.460 --> 03:11.290
And we learned that an index objects in general immutable.

03:11.960 --> 03:17.360
But there is an option to change single entries of our index objects and in the next video we learn

03:17.360 --> 03:19.640
how to do this so I hope to see you there by.
