1
00:00:00,540 --> 00:00:01,350
Hello, welcome back.

2
00:00:01,660 --> 00:00:07,830
In the previous videos, we built this daily graph of average ratings and this video, we are going

3
00:00:07,830 --> 00:00:11,190
to be the same graph, but on a weekly basis.

4
00:00:11,460 --> 00:00:16,380
Now, this is going to be a short video because I'm not going to explain the code because I already

5
00:00:16,380 --> 00:00:16,860
did that.

6
00:00:16,860 --> 00:00:20,050
So you will be able to easily understand what I'm doing.

7
00:00:20,730 --> 00:00:23,520
So let me go back to Visual Studio Code.

8
00:00:24,970 --> 00:00:27,800
And I will create a new file.

9
00:00:28,960 --> 00:00:34,840
I'm going to name this av for average, rat for rating and week.

10
00:00:37,330 --> 00:00:44,920
So that is number two, and what I usually do when I build these graphs is I go to that template of

11
00:00:44,920 --> 00:00:49,810
JustPy and paste it here and then inside here

12
00:00:50,080 --> 00:00:52,570
then I create a new

13
00:00:56,930 --> 00:01:00,800
HighCharts component which which belongs to wp

14
00:01:02,650 --> 00:01:10,450
and as options, it has this chart_def variable, which is going to be a variable in here.

15
00:01:13,630 --> 00:01:23,200
It's going to be a multiline string enclosed in triple quotes, so here now I'm going to find an example

16
00:01:23,200 --> 00:01:24,640
from HighCharts.

17
00:01:25,240 --> 00:01:31,480
So I'm going to use a spline again for this weekly chart, because I think that's the most appropriate

18
00:01:31,480 --> 00:01:35,530
chart type for this kind of analysis, for this kind of visualizations.

19
00:01:36,220 --> 00:01:42,700
So I will click over to jsFiddle, and that will show me the JavaScript code, which is this one

20
00:01:42,700 --> 00:01:43,210
in here.

21
00:01:44,110 --> 00:01:52,690
I can copy all that and go to Python and paste it there and then, of course, delete that part.

22
00:01:53,140 --> 00:02:01,390
So it starts with the first curly bracket before chart and then it ends with a curly bracket.

23
00:02:01,400 --> 00:02:05,470
So I'll delete the semicolon and the parentheses.

24
00:02:06,130 --> 00:02:09,820
So Options points to that doc string.

25
00:02:11,170 --> 00:02:16,800
Before I apply my own data, I first try oout this code to see if it's working.

26
00:02:16,810 --> 00:02:17,800
But first I need to.

27
00:02:19,380 --> 00:02:22,950
Stop the current process with Control C and run.

28
00:02:26,700 --> 00:02:28,940
Go to justpy, reload.

29
00:02:29,670 --> 00:02:30,590
Yeah, it's working.

30
00:02:36,430 --> 00:02:43,030
Next, I want to import pandas, so since I was doing the analysis on Jupyter already, I can just copy

31
00:02:43,030 --> 00:02:44,680
and paste these lines.

32
00:02:48,750 --> 00:02:49,520
Paste them there.

33
00:02:49,680 --> 00:02:51,020
We don't need matplotlib.

34
00:02:51,150 --> 00:02:52,140
I can delete that.

35
00:02:52,800 --> 00:02:54,870
This is our data frame.

36
00:02:54,870 --> 00:02:58,070
Now we need to do some analysis on these data.

37
00:02:59,160 --> 00:03:03,830
So go back to Jupyter and find the weekly analysis.

38
00:03:03,840 --> 00:03:05,070
So that's one in there.

39
00:03:06,180 --> 00:03:08,460
Week average is the data we need.

40
00:03:09,660 --> 00:03:13,290
So paste them below the original data frame.

41
00:03:15,190 --> 00:03:22,080
And we should have this week average now, now week average is going to have as index column the weeks,

42
00:03:22,300 --> 00:03:26,310
so a year and a week that is going to be week average dot index.

43
00:03:26,590 --> 00:03:32,440
And there'll also be a rating column in the week average data frame.

44
00:03:32,590 --> 00:03:36,980
So let's use those those two columns to plot the data.

45
00:03:38,140 --> 00:03:41,290
So we should be accessing hc dot

46
00:03:43,350 --> 00:03:56,670
options dot x axis dot categories for categorical data such as dates, so that would be week average

47
00:03:56,670 --> 00:04:00,390
dot index but in a form of a list.

48
00:04:00,390 --> 00:04:10,140
So we have to convert it into a list for justpy to recognize it and then hc.options.series.data.

49
00:04:12,970 --> 00:04:21,070
So which means series zero gives us this first item, which is a dictionary, so we have

50
00:04:21,090 --> 00:04:25,430
a dictionary here and then we access the data key from that dictionary.

51
00:04:25,440 --> 00:04:29,730
So that will give us actually the value of that key, which is this list.

52
00:04:29,940 --> 00:04:38,880
And we replace that list with another list, which is a week average rating. That should do it.

53
00:04:39,510 --> 00:04:42,090
So stop control C?

54
00:04:44,510 --> 00:04:47,390
Rerun, reload.

55
00:04:48,370 --> 00:04:52,120
And this is a graph, it looks weird because we have to reverse it.

56
00:04:52,390 --> 00:05:02,490
Actually, it's originally reversed, so we should say false as the value of inverted, control C and

57
00:05:02,510 --> 00:05:03,370
rerun.

58
00:05:05,530 --> 00:05:08,540
Reload and this is it.

59
00:05:08,870 --> 00:05:14,890
I'm not going to waste your time and change all these labels as I did in the previous video, so I already

60
00:05:14,890 --> 00:05:15,370
did that.

61
00:05:15,640 --> 00:05:18,370
Therefore, this is enough for this video.

62
00:05:18,400 --> 00:05:19,130
Thanks for following.

63
00:05:19,150 --> 00:05:19,920
I'll talk to you later.

