WEBVTT

00:00.590 --> 00:06.560
Welcome come to the solution for coding exercise for and we have already imparted pandas and also the

00:06.560 --> 00:11.190
listings data set and an exercise 31.

00:11.240 --> 00:18.470
We have to select the arrow index or the roll labels of our data frame listings and we can simply do

00:18.470 --> 00:26.520
this with the index attribute and here we have a Range Index from zero to six thousand eight hundred

00:26.520 --> 00:27.700
fifty two.

00:27.720 --> 00:34.170
Then the next question we have to set the symbol columns of the new index and we can do this the rest

00:34.170 --> 00:39.330
of the set index method and we pass the column later symbol.

00:39.690 --> 00:44.190
And as we want to save for the change we have to pass through to the in-place parameter

00:47.170 --> 00:53.500
and then next we have to check whether the new index or the symbol index contains the unique values

00:53.530 --> 01:04.080
only and no duplicates and we can check this here with the is the unique attribute on the index until

01:04.120 --> 01:04.950
we get a fourth.

01:04.950 --> 01:09.860
So there are apparently duplicates in the index.

01:10.030 --> 01:17.160
And the reason for this is that we have a few companies and a few tickers that are actually listed on

01:17.170 --> 01:19.230
more than one exchange.

01:19.240 --> 01:26.830
So for example on the Nasdaq and the Amex then next year and exercise 35 we should get to the frequency

01:26.830 --> 01:28.960
of the index elements.

01:28.960 --> 01:30.700
And again here we use.

01:30.760 --> 01:33.520
The value counts method on the index

01:37.860 --> 01:42.150
and we have to take us off the companies that are listed on more than one exchange.

01:42.150 --> 01:49.150
So on two exchanges here and finally we can also set a name for our index.

01:49.150 --> 01:55.960
For example the ticker symbol and we can do this by setting the index names so that in addition the

01:56.380 --> 01:58.540
attribute name on our index.

01:58.630 --> 02:03.760
So we set the name here to a ticker symbol and let's have a look here.

02:03.760 --> 02:10.020
So here on the left hand side we can see that here we have the name ticker symbol and finally we can

02:10.020 --> 02:13.240
also reset to the index and create a range index.

02:13.320 --> 02:19.740
With the reset index method and as the we want to save the change also here we have to pass through

02:19.740 --> 02:21.180
to the in-place parameter

02:24.510 --> 02:29.810
and again here we are on the left hand side a Range Index and our form formal index the ticker symbol

02:29.830 --> 02:38.720
is now a column of our data frame and with the columns attribute we can also therefore look at the Columns

02:38.730 --> 02:48.530
index so here we have the column labels the ticker symbol exchanged name and so on and we can also rename

02:48.530 --> 02:50.780
some of these column labels.

02:50.990 --> 02:57.920
So let's assume that you want to rename the column label name to company and market cap to m cap then

02:57.920 --> 03:04.100
we can do the same with the rename method and we determine that you want to change column labels so

03:04.100 --> 03:10.650
we use your columns parameter and then we pass a dictionary both on the left hand side.

03:10.700 --> 03:12.050
The old labels.

03:12.050 --> 03:13.700
So name and market cap.

03:13.700 --> 03:16.230
And that's actually the case of the dictionary.

03:16.400 --> 03:23.630
And as the values of the dictionary we have the new names company and M cap and again will be passed

03:23.760 --> 03:30.080
through to the in-place pair of meta and let's have a look here so here we have successfully changed

03:30.180 --> 03:37.080
the column labels to company and M cap and uh with this we are finished with the solution.

03:37.080 --> 03:42.030
I hope you had fun and uh looking forward to seeing you also in exercise five by.
