WEBVTT

00:00.950 --> 00:07.370
In the last video we have learned how to down sample a time series from high frequency to low frequency.

00:07.370 --> 00:13.100
And we can do this service of the three sample method which is a quite powerful and versatile method.

00:13.100 --> 00:18.920
However there is one thing that is quite inconvenient and that can cause some confusion.

00:18.920 --> 00:26.300
So we have still imparted our temperature data frame with the hourly temperature data and we can actually

00:26.300 --> 00:32.110
convert the frequency from our lead to monthly and we take the mean here.

00:32.150 --> 00:34.550
So this is nothing new.

00:34.860 --> 00:40.910
And if we have for the monthly mean temperature far less angels than New York for each month here and

00:40.910 --> 00:45.890
actually the values here are the mean over ALL TIMESTAMPS in the complete month.

00:45.890 --> 00:49.660
So here we are for the complete month that January to 13.

00:49.820 --> 00:57.890
And for example here eleven point five nine degrees is actually the average of all time stamps in January.

00:57.890 --> 01:01.130
So these values are kind of aggregated data for a period.

01:01.160 --> 01:03.590
So you have for a one month period.

01:03.590 --> 01:10.040
However as a label for the period we have here one day so year at the very last day of the period.

01:10.040 --> 01:16.730
So the thirty first of January and actually the recital method gives us some options here to change

01:17.030 --> 01:23.170
the arrow label or index label so for example instead of having you know the month and we can also have

01:23.170 --> 01:25.610
year the beginning of each month

01:28.290 --> 01:35.240
so you can see instead of having the thirty first of January we have the very first day of January.

01:35.400 --> 01:38.190
So so the aggregated values here are the same.

01:38.190 --> 01:44.790
So these are the mean values for example here for the whole January and we only can change here the

01:44.790 --> 01:45.210
label.

01:45.210 --> 01:51.690
So either we can take the first day or the last day off the period but still here as a label we have

01:51.720 --> 01:59.670
a day and not actually a month and this is kind of inconvenient because we have monthly data for the

01:59.670 --> 02:03.150
whole January and as a label we have one day of January.

02:03.150 --> 02:10.560
So actually it would be better to a simply half year January 213 and ESA the re sample method is quite

02:10.560 --> 02:11.220
versatile.

02:11.220 --> 02:13.280
We can also define this year.

02:13.290 --> 02:17.850
So let's have a look here and here we have to compare me to kind.

02:17.850 --> 02:26.860
So let's have a look at the documentation so the default setting is then on and if it can pass the time

02:26.880 --> 02:34.130
stamp to convert the resulting index to a date time index all we can pass period to convert it to a

02:34.130 --> 02:39.270
period index and by default that the input representation is retained.

02:39.290 --> 02:46.220
So here the input representation of our original temperature data frame is actually a daytime index

02:46.220 --> 02:53.240
and therefore he and our resolve but an aggregate data frame we have here a daytime index this the specific

02:53.240 --> 03:01.780
days and actually now our target would be to convert our next year into a period index.

03:01.880 --> 03:09.650
So let's call here the parameter kind and actually we can either choose a timestamp.

03:09.650 --> 03:14.050
So this is here in our example the default setting actually.

03:14.510 --> 03:16.050
And we can see that.

03:16.070 --> 03:21.880
We get the single timestamps So yeah for the period January we have January the 1st.

03:22.010 --> 03:29.690
And again if you change year from and start to M so month ending then we have here the thirty first

03:29.690 --> 03:39.030
of January the but still this is pretty inconvenient and therefore we pass here the argument period

03:39.060 --> 03:42.060
to the kind parameter so let's try this out here

03:46.330 --> 03:53.500
and now here we can see in our first row instead of having a particular day and January 213 we simply

03:53.500 --> 03:59.710
have it and you read 213 and I think this is a clearer representation of our row because he and our

03:59.710 --> 04:03.130
row we have the aggregated data from January.

04:03.250 --> 04:07.330
So from all days and now here we have the label January.

04:07.330 --> 04:12.840
So this is quite convenient and does not to cause any confusion here.

04:13.240 --> 04:16.990
And actually the same we can do also with other frequency.

04:16.990 --> 04:19.690
So for example for weekly frequency.

04:19.710 --> 04:25.970
So let's try this out here and for weekly frequencies we actually get here as labels.

04:26.020 --> 04:32.350
Let's start off the week and actually the end of the week and by default if you pass the only w then

04:32.350 --> 04:39.820
the start of the week is a Monday and the end of the week is a Sunday and still in addition we can define

04:39.820 --> 04:46.570
you whether we want to have weeks from Monday to Sunday or from Thursday to Wednesday whatever.

04:46.570 --> 04:48.700
So this is C a completely flexible.

04:48.940 --> 04:51.480
And let's go to quarterly

04:54.610 --> 05:00.740
and we can see on the left hand side in the index as in next Lavers and set off having the very first

05:00.740 --> 05:04.100
day or the very last day off the quarter.

05:04.100 --> 05:08.190
Now we have from Q1 into 13 Q2 and so on.

05:08.600 --> 05:14.040
So this is definitely more intuitive than having one single day of the quarter.

05:14.060 --> 05:20.600
All right and last but not least we can also change um the frequency to Anya

05:23.320 --> 05:28.950
and we simply have on the left hand side and the year so to 13 to 14 to 15.

05:28.990 --> 05:34.270
And also here this is more intuitive than having here a single day of the year.

05:34.270 --> 05:34.680
All right.

05:34.690 --> 05:42.670
Now let's convert the frequency of our temperature data frame to a monthly and we pass period to the

05:42.700 --> 05:48.870
kind parameter and we take the mean and we store the aggregate data frame in the rabbit temperature.

05:48.870 --> 05:55.000
Uh monthly and let's have a look at our new data frame.

05:55.020 --> 05:57.190
So here we have the monthly temperature.

05:57.210 --> 05:59.190
And on the left hand side.

05:59.250 --> 05:59.450
Yeah.

05:59.460 --> 06:06.930
We do not have a date time index with a specific day but the FAA period index indicating the periods

06:06.930 --> 06:08.380
of our data frame.

06:08.400 --> 06:16.020
So here we have the aggregate data for January and we have January and we can also call here the Inform

06:16.020 --> 06:24.050
method and we can see here instead of having a daytime index we now have a period indexed with the 48

06:24.060 --> 06:25.270
entries.

06:25.530 --> 06:35.840
So we have 48 months from January to 30 into December to a 16 with a monthly frequency and we can also

06:35.840 --> 06:46.090
call the index attribute and we can see that we have a period index and we have all of these specific

06:46.090 --> 06:46.530
periods.

06:46.540 --> 06:53.080
So January to 30 in February to 13 and so on and we can also select a single element.

06:53.110 --> 07:00.870
So for example the very first element and this was c a not a timestamp but a period.

07:00.920 --> 07:06.260
So we have here January 213 and the frequency is month.

07:06.260 --> 07:13.910
All right let's plot again our data and first of all we plot our original data frame with our data and

07:13.910 --> 07:16.910
we can see here that this is actually quite messy.

07:16.940 --> 07:23.750
So we have many data points and as the FBI our data we FBI the daily oscillations so from day to night

07:24.350 --> 07:29.020
and by down sampling our data we can actually smooth our data.

07:29.360 --> 07:36.830
So by down sampling it from our lead to monthly we can actually remove the daily oscillation of fluctuation

07:36.860 --> 07:44.750
between day and night and therefore let's plot here our new aggregated data frame temperature monthly

07:47.320 --> 07:51.190
and we can see that we have smooth and our data.

07:51.430 --> 07:59.550
So here we have clear lines this monthly data our monthly averages and year by smoothing the line plots.

07:59.560 --> 08:02.560
We can see even better that we have some seasonality.

08:02.980 --> 08:10.000
So the summers are warmer than the winter us and we cannot really say that the summers in L.A. are warmer

08:10.030 --> 08:10.920
than in New York.

08:11.170 --> 08:17.440
So the temperatures here are quite similar but it's quite significant that the vendors in New York are

08:17.440 --> 08:21.370
much colder than the vendors in Los Angeles here.

08:21.370 --> 08:26.080
All right we are finished now with this video and I hope to see also in the next one by.
