WEBVTT

00:01.180 --> 00:07.720
In this video we will learn some very helpful daytime indexed methods and attributes and with these

00:07.720 --> 00:13.870
methods and attributes you can for example create additional features for what data frame containing

00:13.870 --> 00:18.520
some kind of customized the representation of date or time.

00:18.530 --> 00:24.100
So let's first of all import pandas and we import our stocks.

00:24.140 --> 00:30.960
CSC and we set the date column as being the date time index.

00:31.120 --> 00:39.130
So let's have a look here and then we only selected the opening prices for our six stocks and we are

00:39.130 --> 00:45.590
creating a copy and start a new data frame and the variable clothes.

00:45.790 --> 00:47.380
So let's have a look here.

00:47.590 --> 00:53.780
So this is our close data frame with daily closing prices for our six stocks.

00:54.430 --> 01:01.310
And it's also called here the info method and we can see here that we have a daytime index with actually

01:01.310 --> 01:09.870
a daily timestamps and with the index attribute we can also have a closer look at our day time index.

01:09.910 --> 01:13.890
So here we have the daytime index to the timestamps.

01:13.930 --> 01:18.970
So in total we have two thousand two hundred and ninety Daily Times stems.

01:19.120 --> 01:21.930
And here we can see for example for one time stamp.

01:21.940 --> 01:25.820
So here we have the fourth of January 2010.

01:25.960 --> 01:33.540
And it might be quite helpful to get you additional information or different representation of the date.

01:33.550 --> 01:37.750
So for example it might be useful to have the day off the week.

01:37.750 --> 01:41.910
So for example Tuesday or Wednesday or the quarter of the year.

01:41.920 --> 01:49.510
So here in this example it's the first quarter and we can do this with quite a head for attributes and

01:49.510 --> 01:51.600
methods on the index.

01:52.150 --> 02:00.900
So first of all we FCB they attribute and we get actually the day of the month.

02:00.910 --> 02:06.430
So for example in our first time stamp we have for the thirty first of December and here we get the

02:06.460 --> 02:07.510
thirty first.

02:07.540 --> 02:14.890
So that data types see an integer and consequently we get you for the other timestamps for example here

02:14.950 --> 02:23.440
for 10 we get 5 and so on and we can also get an integer representation of the month and we can do this

02:23.680 --> 02:26.060
for the month at tribute.

02:26.080 --> 02:33.550
So here we have the data type in the data and we get twelve here for the timestamp in December and one

02:33.550 --> 02:41.890
for the time stamps in January and so on Next we can also get the year with the year attribute.

02:42.640 --> 02:45.970
So here again we have integer data types.

02:45.970 --> 02:49.500
2009 2010 and so on.

02:49.870 --> 02:56.380
And for each row off each time stamp and our data frame we can also get to the day of the week or the

02:56.380 --> 03:07.230
day name with the method day name so here we have a Thursday Monday Tuesday and so on and we can actually

03:07.230 --> 03:16.770
do the very same with the attribute week name all week day name and typical actually the same week day

03:16.770 --> 03:21.660
names and also instead of getting an integer representation of the month.

03:21.690 --> 03:32.030
So here twelve one 2 Three you can get the month name so you have with the method the month name and

03:32.040 --> 03:32.780
t we get.

03:32.790 --> 03:35.340
December January February and so on.

03:35.880 --> 03:44.170
So next we have to attribute to weekday and instead of getting here the string representation first

03:44.170 --> 03:50.610
day Monday Tuesday we get an intense representation so zero stands for Monday.

03:50.710 --> 04:00.320
Then one stands for Tuesday and so on and we can also get the quarter with the quarter attribute and

04:00.320 --> 04:07.460
by default the first quarter is from January to March the second from April to June and so on.

04:07.460 --> 04:14.330
So we can see for the time stamp in December we get a far and for the time stamps and January a one

04:14.390 --> 04:15.750
as in the jar.

04:15.810 --> 04:24.380
Then next we have also the attributed days and month and TV get for each row off each time stamp the

04:24.380 --> 04:28.100
amount of days in the respective month.

04:28.100 --> 04:39.240
So in December we have 31 and January 31 and so on and next that s also the week at tribute and TV we

04:39.250 --> 04:45.850
get actually the calendar week saw the very last week in December as the week fifty.

04:45.880 --> 04:53.860
Then the very first week in January is the week 1 and so on and the same we can actually get with the

04:53.890 --> 04:57.810
attribute week off year.

04:57.920 --> 05:06.500
So this is the same and that's another attribute court is month and and year pen us checks for each

05:06.500 --> 05:12.950
row of each time stem whether the day is actually the very last day of the month.

05:13.550 --> 05:17.960
So here we have for the thirty first of December a true.

05:17.960 --> 05:22.070
And for the 1st of January or for the second a fourth.

05:22.850 --> 05:30.570
So these are some very helpful attributes and methods on the daytime index and that even more methods

05:30.580 --> 05:33.140
so feel free to have a closer look.

05:33.140 --> 05:38.300
And now we can also create new columns and new features for our data frame.

05:38.300 --> 05:45.920
So for example we want to have the day name as the new feature and we can create yet a new column called

05:45.920 --> 05:46.510
day.

05:46.580 --> 05:50.580
And we want to have the quarter as the new column on your feet.

05:51.020 --> 05:56.480
So let's do this here and let's have a look here at our new data frame.

05:56.480 --> 06:01.260
So here we have our adjusted close that frame where we have you on the right hand side.

06:01.340 --> 06:08.480
The two additional columns day and quarter and year for each row off each timestamp we have here the

06:08.480 --> 06:10.640
weekday day and the quarter.

06:11.060 --> 06:17.780
So creating additional features with different representation of date might be in some cases quite helpful.

06:18.320 --> 06:20.570
And with this we are finished now.

06:20.570 --> 06:23.510
And I hope to see you also in the next video by.
