WEBVTT

00:01.320 --> 00:08.050
In this video we learn how to index lost life time series for particular timestamps or time periods.

00:08.100 --> 00:14.960
So for example we can only select the temperance information for the year 2015 or for the month made

00:14.980 --> 00:16.370
to 14.

00:16.380 --> 00:17.930
And we can simply do this.

00:17.920 --> 00:19.860
This is the loke operator.

00:20.340 --> 00:27.930
But first of all let's import pandas and for indexing and slicing time series we need to have a date

00:27.930 --> 00:30.270
time indexed in our data frame.

00:30.350 --> 00:32.330
And this is exactly what we are doing here.

00:32.360 --> 00:38.590
So we are importing our CSP fire temperature and we are passing the column daytime to the parameters

00:38.590 --> 00:43.110
past states and index columns.

00:43.310 --> 00:49.470
So now give we f on the left hand side our daytime index and we can also confirm this with the input

00:49.490 --> 00:50.380
method.

00:50.390 --> 00:52.900
So here we have the daytime index.

00:53.330 --> 01:00.770
And same with all other indexes we can select and slice for index labels by using the local operator

01:00.970 --> 01:02.500
service for the log operator.

01:02.530 --> 01:09.290
We can perform labor based indexing and give us a daytime and next hour labors are actually here day

01:09.290 --> 01:10.270
times.

01:10.430 --> 01:16.070
And let's assume that we only want to select the one time stamps or flag sample here the first of January

01:16.070 --> 01:25.010
to 13 at 1:00 a.m. and we can simply do this by passing the timestamp as a string here to the.

01:25.010 --> 01:32.290
Operator And until we can see the temperature information for the specific time stamp here.

01:32.290 --> 01:39.430
So we have here of 1:00 and in L.A. We have ten point seven degrees and in New York minus one point

01:39.430 --> 01:39.880
seven.

01:39.880 --> 01:40.560
So here.

01:41.170 --> 01:47.150
So here we pass an entire timestamp with information on the date and also on the time.

01:47.170 --> 01:48.350
So 1:00.

01:48.460 --> 01:51.840
But we can also pass only to 15.

01:52.000 --> 01:56.660
And by doing so we are selecting all of those are all timestamps in the year to 15.

01:56.660 --> 01:58.450
So let's try this out here.

02:00.700 --> 02:02.430
And here we can see that.

02:02.470 --> 02:10.990
Here we have timestamps to 15 starting from the very first timestamp at the January the 1st at midnight.

02:11.470 --> 02:20.210
And so we have your all time stamps into 15 with hourly increments and uh the very last row we have

02:20.210 --> 02:26.240
here the thirty first of December to 15 at 11:00 p.m..

02:26.240 --> 02:31.880
So these are all time stamps in the year to 15 and in total we have eight thousand seven hundred and

02:31.880 --> 02:36.730
sixty arose time stamps and we can also slice for particular month.

02:36.770 --> 02:45.190
So for example here for May 215 and here we are getting all the time stamps and the May 215.

02:45.330 --> 02:51.070
Starting from the 1st of May midnight onto the uh thirty first.

02:51.090 --> 02:54.570
Uh 11:00 in the evening.

02:54.570 --> 02:59.040
And in total we have seven hundred forty four rows of timestamps.

02:59.040 --> 03:01.680
And of course we can also select a single day.

03:01.680 --> 03:06.620
So for example here the 20th of uh May 2015

03:10.190 --> 03:13.550
and I think we should get to twenty four rows.

03:13.580 --> 03:15.040
So we have our early data.

03:15.080 --> 03:19.670
And one day so let's check here other save

03:23.670 --> 03:30.350
and we have 24 rows so far each hour on the 20th of May 2015.

03:30.540 --> 03:32.300
And we can also add to your time data.

03:32.310 --> 03:36.210
So if like stop at 10:00 for the 20th of May.

03:38.010 --> 03:39.030
And this also works.

03:39.060 --> 03:41.330
So here this is the one single time stamp.

03:41.850 --> 03:45.750
And in theory we can also add information on the minutes and seconds here.

03:45.750 --> 03:54.020
So for example here we have 10 30 by two we get an error message because we have only hourly data.

03:54.150 --> 03:57.800
So that is no timestamp 10 30.

03:58.050 --> 03:58.870
All right.

03:58.970 --> 04:02.010
And we can also index lost lies for time period.

04:02.030 --> 04:08.550
So for example from January the 1st to 15 until the very last day to 15.

04:08.630 --> 04:11.220
So let's try this out here.

04:11.390 --> 04:15.740
So we are starting here at midnight on January the 1st.

04:15.800 --> 04:22.490
And the last timestamp is at 11:00 at the thirty first.

04:22.490 --> 04:28.970
And actually slicing from the 1st of January and to the thirty first of December it's actually identical

04:28.970 --> 04:31.610
to a slicing only for the year to 15.

04:32.480 --> 04:41.220
So we can check this myth that the equals method and we should get you a true however of course we live

04:41.220 --> 04:42.950
for this life and notation.

04:43.040 --> 04:44.620
We can be more versatile.

04:44.980 --> 04:54.640
So for example we can also slice from the 15th of April to 15 to the twenty third of February to a 16

04:57.030 --> 05:01.530
so obviously in this case we cannot only pass here to 15 after 16

05:04.770 --> 05:13.690
and we can also slice from the 20th of May to 15 and to the very last timestamp so here we are starting

05:13.690 --> 05:18.140
with the 20th of May and the very last timestamp is here.

05:18.430 --> 05:26.110
The very last timestamp in our data frame so the thirty first of December to 60 the 11:00 p.m.

05:29.150 --> 05:32.610
and you can also slice our data frame from the beginning until.

05:32.630 --> 05:36.740
For example um the 20th of May 215.

05:37.010 --> 05:43.400
So here we are starting into 13 and to the 20th of May to 15.

05:43.400 --> 05:48.740
11:00 and same as service for the two daytime method.

05:48.910 --> 05:53.020
Pandas can handle here all kinds of formats.

05:53.050 --> 06:00.640
So for example here we can select for the 20th of February to 15 and we can do this in different formats

06:00.640 --> 06:04.910
here for example in this format and this still works here.

06:06.760 --> 06:16.620
So starting from midnight to 11:00 p.m. However there's one thing that we cannot do.

06:16.740 --> 06:20.430
So let's assume that we want to select several single timestamp.

06:20.430 --> 06:29.960
So for example here the 20th of May 250 and 10:00 and the 20th of May to 50 and 12:00.

06:30.060 --> 06:32.410
And this does not work here.

06:32.550 --> 06:39.210
And in this case first of all we have to transform the two timestamps into a date time index and we

06:39.210 --> 06:43.350
can do this with the method PD got to date time.

06:43.440 --> 06:46.350
So we are passing here a list of the two time stamps.

06:46.390 --> 06:53.860
And let's see what we get here and we are getting it actually the daytime index this hour two time stamps.

06:54.000 --> 06:59.670
And now we can index our data frame that's at the clock operator by passing here the date time index

07:01.380 --> 07:06.160
and by doing so we are getting the two time stamps so 10:00 and twelve o'clock.

07:06.180 --> 07:11.340
And the information for Los Angeles and New York are right.

07:11.340 --> 07:18.250
This is also the video on indexing and slicing time series and with a day time index anti-lock operator.

07:18.350 --> 07:23.510
This is actually quite easy and versatile and with this uh we are finished here and I hope to see you

07:23.510 --> 07:25.430
also in the next video by.
