WEBVTT

00:00.380 --> 00:06.880
To come to the solution for coding exercise 10 and impart the pandas and plop lip.

00:06.870 --> 00:14.400
And then we import a CSB file with historical stock price data for Apple and Facebook and we can do

00:14.400 --> 00:23.860
the service of the CSB method and we pass the the column data to the pass data parameter to get um a

00:23.880 --> 00:32.250
daytime format and also we pass the date column to the index called parameter to create a date time

00:32.280 --> 00:32.840
index.

00:32.850 --> 00:40.370
So that's a common workflow here when working with time serious and pandas and be safe.

00:40.410 --> 00:46.590
The resulting data frame and the rabbit stocks and the Christmas year how many timestamps does the stocks

00:46.590 --> 00:57.410
contain so let's have a look here with the info method and we can see that we have 1000 and 5 timestamps

00:57.440 --> 01:04.800
or days and the second question is what was the minimum stock price for Facebook in that period.

01:05.030 --> 01:09.770
And we can determine this of a study described method.

01:09.770 --> 01:16.240
So here we are Facebook and the maximum value is two hundred seventeen point five dollars.

01:16.310 --> 01:23.710
Then we can also visualize that the evolution of stock prices over time with a line plot and we can

01:23.710 --> 01:26.070
simply do the service of the plot method.

01:27.890 --> 01:34.910
So here we have on the x axis the daytime index and on the y axis the stock prices and Apple and blue

01:34.910 --> 01:37.940
and Facebook and green.

01:37.980 --> 01:44.410
Here we have to select one single timestamp but the 13th of May 2016.

01:44.580 --> 01:47.290
And the question is what is the price for Apple.

01:47.400 --> 01:51.660
And we have to pass the date in a string format to the local operator.

01:51.990 --> 01:59.370
So there are many string formats that actually work here and this is probably of the most commonly used

01:59.370 --> 02:00.030
format.

02:00.060 --> 02:04.700
So here we have the 13th of May 2016.

02:04.860 --> 02:10.800
And on that day the Apple stock price was ninety point five two.

02:11.040 --> 02:15.090
Next we have to select our stock prices in September 2017.

02:15.090 --> 02:24.060
So far trading days and calculate the mean over those days for both stocks and also here we can pass

02:24.120 --> 02:33.350
September to 17 as a string to the local operator and then we change the mean method so airports I mean

02:33.380 --> 02:41.060
price in September to 17 was one hundred fifty seven point six one in the next question we have to create

02:41.090 --> 02:42.320
a single timestamp.

02:42.380 --> 02:49.640
So the 10th of August 2019 and we we've learned that there are many alternatives and options so we can

02:49.640 --> 02:53.150
pass a date in a different string formats.

02:53.210 --> 02:54.630
And here are two alternatives.

02:54.650 --> 03:02.770
So we have the 10th of August to 19 or we can use the 10th of August to 19 and both alternatives works

03:02.790 --> 03:04.760
uh in the same way.

03:04.760 --> 03:10.460
So here we get the timestamp tenths of August to 19 at midnight.

03:10.610 --> 03:12.200
Then he can exercise ninety five.

03:12.230 --> 03:17.060
We have to create a daytime indexed service for 31 days of July to 19.

03:17.270 --> 03:23.210
And essentially here we have uh three alternatives how to do this because we have uh three parameters

03:23.660 --> 03:26.150
and we have to use two of them.

03:26.150 --> 03:33.370
So we have start and and the periods parameter and not turn it off when we use the start parameter.

03:33.400 --> 03:40.670
So the start date is uh the first of July to nineteen and you want to have 31 periods and the frequency

03:40.670 --> 03:42.390
is daily.

03:42.770 --> 03:47.290
So here we have a daytime index with all days in July.

03:47.570 --> 03:51.370
Then next we can also use the combination of start and end.

03:51.500 --> 03:59.850
So status of the first of July and so the thirty first of July and finally we can also use the combination

03:59.850 --> 04:02.110
of end and periods.

04:02.130 --> 04:06.850
So this gives us the same date time index.

04:06.900 --> 04:11.370
Now we are getting to the more special cases and we should credit daytime in next starting from the

04:11.370 --> 04:20.520
17th of May to 19 and including the following nine Fridays so the 17th of May 219 as of Friday and we

04:20.520 --> 04:24.910
want to have also the following nine Fridays so in total ten Fridays.

04:25.230 --> 04:32.820
And uh we can do this here again with the the date range method and we set the start date to the 17th

04:32.820 --> 04:34.050
of May 219.

04:34.170 --> 04:40.170
We want to have 10 periods and as a frequency want to have weekly Friday

04:42.840 --> 04:48.730
A.B. F. The 10 Fridays next we have to create a daytime indexed service for the 12th of November for

04:48.730 --> 04:58.030
the Yes to 19 to 223 and we can do this again with the PD that date range method and we pass the tests

04:58.030 --> 05:06.530
of November to 9 into the start parameter we have 5 periods and this frequency we pass uh The Pen the

05:06.550 --> 05:10.380
start date offset method and thus increment.

05:10.450 --> 05:12.280
We have one year.

05:12.280 --> 05:17.310
So let's have a look here and we have uh five times.

05:17.410 --> 05:19.420
The 12th of November.

05:19.620 --> 05:21.420
So that was coding exercise 10.

05:21.420 --> 05:25.620
I hope you had fun and I see you also in the next exercise by.
