WEBVTT

00:00.890 --> 00:07.010
This is a short wrap up of the period index up ticked so in previous videos we learned that we can either

00:07.010 --> 00:14.630
have a date time index of Earth time stamps or a period index those periods and sometimes that might

00:14.630 --> 00:16.850
be clear up to half a period index.

00:16.850 --> 00:22.780
So for example if we have aggregated monthly data then it might be more appropriate to have periods

00:22.800 --> 00:23.910
labels.

00:24.020 --> 00:28.060
However in this video I want to show you some pitfalls are unexpected.

00:28.050 --> 00:35.240
The behavior of period indexes and that's actually why in most cases I definitely prefer a date time

00:35.240 --> 00:36.350
index.

00:36.350 --> 00:43.700
So first of flag we import pandas and we are working with our temperate set dataset and we are creating

00:43.730 --> 00:46.430
a daytime index so let's have a look here.

00:49.170 --> 00:56.590
So here we have on the left hand side a daytime index with hourly data or hourly increments.

00:56.680 --> 01:02.400
Now let's assume that you want to read sample the data and you want to create a monthly frequency and

01:02.400 --> 01:08.190
we can do this with the risk pool method and actually we can select that we say we want to have a daytime

01:08.260 --> 01:15.240
index by bypassing a timestamp to the prior meter and we take them in and be safe.

01:15.240 --> 01:21.600
Then you aggregated data frame and the variable temperature monthly so let's do this.

01:21.600 --> 01:28.170
So here we have our aggregated data frame with monthly aggregated data and on the left hand side we

01:28.170 --> 01:33.510
can see our daytime and next by default we have fear the very last day of each period.

01:33.510 --> 01:41.160
So the very last day of each month and we can also check again here a 30 inform method and we can also

01:41.160 --> 01:43.900
call here the index attribute.

01:44.280 --> 01:50.250
So at zero day time index and we've already learned that we can index and slice the time series with

01:50.280 --> 01:51.490
a daytime index.

01:51.550 --> 01:53.420
This the cloak operator.

01:53.820 --> 01:56.000
So here for example we want to select.

01:56.040 --> 02:02.150
January 2 13 and we get 1 row of course.

02:02.200 --> 02:13.940
So it's this one year and we can also slice our time series for example from May to 30 into August 213.

02:14.270 --> 02:16.350
And here we get four rows.

02:16.360 --> 02:22.620
So both ends are here actually including and we can simply pass here to a in.

02:22.630 --> 02:30.910
And by doing so we are actually getting all month in the year to 30 and so starting from January into

02:30.940 --> 02:31.640
December.

02:31.930 --> 02:33.940
So in total we I feel twelfth rows.

02:34.600 --> 02:38.080
So this is the behavior when we have a daytime index.

02:38.710 --> 02:49.230
But now let's create a period index by passing year to the kind per meter period.

02:49.560 --> 02:53.700
So again we are aggregating our data from our little monthly.

02:54.840 --> 03:00.840
So I can hear the values in our data frame are exactly the same but we have actually changed to the

03:00.960 --> 03:06.770
next layer of us from one day and the respective periods to the respective periods.

03:06.780 --> 03:10.830
So here we have January February and before we head to one specific day.

03:10.830 --> 03:17.390
So for example the last day or the first day of the period and let's check also you have to the Inform

03:17.390 --> 03:17.820
method.

03:17.850 --> 03:24.840
So we changed you from day time index to period index and we can also confirm this here.

03:26.350 --> 03:33.400
Now let's again assume that we only want to select the very first draw here in January to 13.

03:33.610 --> 03:42.130
So we can do this also with a period index and actually the values here are the same as before but before

03:42.130 --> 03:44.940
we got a data frame now we have a pen not serious.

03:44.940 --> 03:46.560
So no problem here.

03:46.810 --> 03:57.920
And we can also slice our period index from May to August so here we get exactly the same values and

03:57.980 --> 03:59.740
the same structure.

03:59.760 --> 04:05.000
And let's assume that you want to filter for all rows so all periods in the year 230.

04:05.360 --> 04:07.700
So we simply pass the 213.

04:07.700 --> 04:14.040
And now comes the surprise that we only get the very first row into 13.

04:14.090 --> 04:22.710
So here we can see we only get the January 230 and not all 24 hour rows or twelve periods off to 13.

04:22.880 --> 04:30.590
And therefore it might be an option to change to the period index back to a date time index and we can

04:30.590 --> 04:33.410
do this with the method to timestamp.

04:33.680 --> 04:40.840
So we use the method to timestamp on our data frame temperature monthly which has a period index.

04:41.190 --> 04:47.540
And let's try this out here so as to here we have our aggregated monthly data.

04:47.570 --> 04:51.530
But instead of having you on the left hand side a period and next.

04:51.530 --> 04:57.540
Now again we have a date time index and by default we have for the very first day of the period.

04:57.560 --> 05:01.790
So the first of each month and that's the parameter how

05:04.920 --> 05:10.560
so we can define whether we want to have the start of the period or the end and if we can pass either

05:10.560 --> 05:15.260
start R and R S or e so we can also try.

05:15.280 --> 05:15.510
Yeah.

05:15.540 --> 05:15.930
And

05:19.870 --> 05:25.830
until we get actually the very last timestamp of each month and we have actually nominal stacking positions

05:25.840 --> 05:29.050
so that's why we have many nines and uh.

05:29.080 --> 05:31.000
So it's better to have a start

05:34.480 --> 05:35.680
and actually as a summary.

05:35.680 --> 05:42.880
So this is my personal taste that as far as I can I definitely stick to a day time index.

05:42.970 --> 05:49.960
So I feel comfortable or more comfortable with a day time index but as I said this is a matter of taste.

05:49.960 --> 05:54.340
And if you're like You can also dig deeper into the period index.

05:54.430 --> 05:56.720
So feel free to do this.

05:56.890 --> 06:02.350
And with this we are finished with this video and I hope to see you also in the next one by.
