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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"id": "089fb047",
|
6 |
+
"metadata": {},
|
7 |
+
"source": [
|
8 |
+
"# Workflow of QuizTube 🧠"
|
9 |
+
]
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"cell_type": "markdown",
|
13 |
+
"id": "f7cf0634",
|
14 |
+
"metadata": {},
|
15 |
+
"source": [
|
16 |
+
"## 1. Extract the YouTube ID from a given link"
|
17 |
+
]
|
18 |
+
},
|
19 |
+
{
|
20 |
+
"cell_type": "code",
|
21 |
+
"execution_count": 1,
|
22 |
+
"id": "8415cbde",
|
23 |
+
"metadata": {},
|
24 |
+
"outputs": [
|
25 |
+
{
|
26 |
+
"name": "stdout",
|
27 |
+
"output_type": "stream",
|
28 |
+
"text": [
|
29 |
+
"SA2iWivDJiE\n",
|
30 |
+
"_oPAwA_Udwc\n",
|
31 |
+
"SA2iWivDJiE\n",
|
32 |
+
"SA2iWivDJiE\n",
|
33 |
+
"rTHlyTphWP0\n",
|
34 |
+
"n0g-Y0oo5Qs\n"
|
35 |
+
]
|
36 |
+
}
|
37 |
+
],
|
38 |
+
"source": [
|
39 |
+
"from pytube import extract\n",
|
40 |
+
"\n",
|
41 |
+
"urls = [\n",
|
42 |
+
" 'http://youtu.be/SA2iWivDJiE',\n",
|
43 |
+
" 'http://www.youtube.com/watch?v=_oPAwA_Udwc&feature=feedu',\n",
|
44 |
+
" 'http://www.youtube.com/embed/SA2iWivDJiE',\n",
|
45 |
+
" 'http://www.youtube.com/v/SA2iWivDJiE?version=3&hl=en_US',\n",
|
46 |
+
" 'https://www.youtube.com/watch?v=rTHlyTphWP0&index=6&list=PLjeDyYvG6-40qawYNR4juzvSOg-ezZ2a6',\n",
|
47 |
+
" 'https://www.youtube.com/watch?time_continue=9&v=n0g-Y0oo5Qs&feature=emb_logo'\n",
|
48 |
+
"]\n",
|
49 |
+
"\n",
|
50 |
+
"for url in urls:\n",
|
51 |
+
" video_id = extract.video_id(url)\n",
|
52 |
+
" print(video_id)"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
{
|
56 |
+
"cell_type": "markdown",
|
57 |
+
"id": "cc0e3642",
|
58 |
+
"metadata": {},
|
59 |
+
"source": [
|
60 |
+
"## 2. Extract & transform video captions"
|
61 |
+
]
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"cell_type": "code",
|
65 |
+
"execution_count": 2,
|
66 |
+
"id": "0809fc83",
|
67 |
+
"metadata": {},
|
68 |
+
"outputs": [
|
69 |
+
{
|
70 |
+
"data": {
|
71 |
+
"text/plain": [
|
72 |
+
"[{'text': 'Okay, some of you might have heard already,\\nbut you can now use Python inside Excel.',\n",
|
73 |
+
" 'start': 0.13,\n",
|
74 |
+
" 'duration': 4.74},\n",
|
75 |
+
" {'text': \"In this video, I will show some basic examples\\nof how to use it, and I'll guide you through\",\n",
|
76 |
+
" 'start': 4.87,\n",
|
77 |
+
" 'duration': 5.2},\n",
|
78 |
+
" {'text': 'a real-world example to give you an idea of\\nthe possibilities.',\n",
|
79 |
+
" 'start': 10.07,\n",
|
80 |
+
" 'duration': 4.199},\n",
|
81 |
+
" {'text': \"In that example, I'll show you some very useful\\npandas features and some more advanced charts.\",\n",
|
82 |
+
" 'start': 14.269,\n",
|
83 |
+
" 'duration': 5.301},\n",
|
84 |
+
" {'text': \"Towards the end, I'll also share my personal\\nopinion about this new feature and point out\",\n",
|
85 |
+
" 'start': 19.57,\n",
|
86 |
+
" 'duration': 4.58},\n",
|
87 |
+
" {'text': 'some limitations.', 'start': 24.15, 'duration': 1.26},\n",
|
88 |
+
" {'text': 'But, before we start, a quick shout-out to\\nLuke.',\n",
|
89 |
+
" 'start': 25.41,\n",
|
90 |
+
" 'duration': 3.1},\n",
|
91 |
+
" {'text': 'Luke was kind enough to connect me with people\\nfrom Anaconda so that I could test this feature.',\n",
|
92 |
+
" 'start': 28.51,\n",
|
93 |
+
" 'duration': 4.93},\n",
|
94 |
+
" {'text': 'So, thank you very much, Luke and the team\\nfrom Anaconda.',\n",
|
95 |
+
" 'start': 33.44,\n",
|
96 |
+
" 'duration': 3.45},\n",
|
97 |
+
" {'text': \"And with that said, let's dive in.\",\n",
|
98 |
+
" 'start': 36.89,\n",
|
99 |
+
" 'duration': 2.17},\n",
|
100 |
+
" {'text': \"Ok, let's start with a basic example.\",\n",
|
101 |
+
" 'start': 39.06,\n",
|
102 |
+
" 'duration': 2.72},\n",
|
103 |
+
" {'text': \"Under the formulas ribbon, there's a new Python\\nsection.\",\n",
|
104 |
+
" 'start': 41.78,\n",
|
105 |
+
" 'duration': 3.549},\n",
|
106 |
+
" {'text': \"When I click on the Python logo, you'll notice\\nthat the appearance of the formula bar changes.\",\n",
|
107 |
+
" 'start': 45.329,\n",
|
108 |
+
" 'duration': 5.5},\n",
|
109 |
+
" {'text': 'This is where you can now write your Python\\ncode.',\n",
|
110 |
+
" 'start': 50.829,\n",
|
111 |
+
" 'duration': 2.691},\n",
|
112 |
+
" {'text': 'For the first step, I\\'ll create a dataframe\\nwith the command \"df is equal to\", and then',\n",
|
113 |
+
" 'start': 53.52,\n",
|
114 |
+
" 'duration': 5.03},\n",
|
115 |
+
" {'text': 'simply select my Excel table here on the left.',\n",
|
116 |
+
" 'start': 58.55,\n",
|
117 |
+
" 'duration': 2.82},\n",
|
118 |
+
" {'text': \"It doesn't have to be a table, by the way;\\na normal cell range will also work.\",\n",
|
119 |
+
" 'start': 61.37,\n",
|
120 |
+
" 'duration': 4.24},\n",
|
121 |
+
" {'text': 'To execute the code, I will press Ctrl + Enter.',\n",
|
122 |
+
" 'start': 65.61,\n",
|
123 |
+
" 'duration': 3.2},\n",
|
124 |
+
" {'text': 'If you just press Enter, it will insert a\\nnew line.',\n",
|
125 |
+
" 'start': 68.81,\n",
|
126 |
+
" 'duration': 2.91},\n",
|
127 |
+
" {'text': 'So now, the data source is now your table.',\n",
|
128 |
+
" 'start': 71.72,\n",
|
129 |
+
" 'duration': 2.74},\n",
|
130 |
+
" {'text': 'In my case, the table is named IrisDataSet,\\nand as it is correctly recognized, it has',\n",
|
131 |
+
" 'start': 74.46,\n",
|
132 |
+
" 'duration': 4.89},\n",
|
133 |
+
" {'text': 'a header row.', 'start': 79.35, 'duration': 1.0},\n",
|
134 |
+
" {'text': 'In the cell where I wrote the Python code,\\nthe dataframe object now appears.',\n",
|
135 |
+
" 'start': 80.35,\n",
|
136 |
+
" 'duration': 3.53},\n",
|
137 |
+
" {'text': 'So, as you might already know, everything\\nin Python is an object, and we can store that',\n",
|
138 |
+
" 'start': 83.88,\n",
|
139 |
+
" 'duration': 5.3},\n",
|
140 |
+
" {'text': 'object in a cell.', 'start': 89.18, 'duration': 1.52},\n",
|
141 |
+
" {'text': 'I can also get a preview of what the dataframe\\nlooks like when I click on the icon.',\n",
|
142 |
+
" 'start': 90.7,\n",
|
143 |
+
" 'duration': 4.33},\n",
|
144 |
+
" {'text': 'It gives me a preview of the dataframe.',\n",
|
145 |
+
" 'start': 95.03,\n",
|
146 |
+
" 'duration': 4.06},\n",
|
147 |
+
" {'text': 'Now that we have our dataframe, you can use\\nall the different Pandas functions.',\n",
|
148 |
+
" 'start': 99.09,\n",
|
149 |
+
" 'duration': 3.96},\n",
|
150 |
+
" {'text': \"I named my dataframe 'df', so in the next\\ncell, I just need to type 'df'.\",\n",
|
151 |
+
" 'start': 103.05,\n",
|
152 |
+
" 'duration': 5.54},\n",
|
153 |
+
" {'text': \"And for this example, I will use the 'describe'\\nmethod to get some statistical insights into\",\n",
|
154 |
+
" 'start': 108.59,\n",
|
155 |
+
" 'duration': 4.48},\n",
|
156 |
+
" {'text': 'the data.', 'start': 113.07, 'duration': 1.079},\n",
|
157 |
+
" {'text': 'When I execute the cell using Ctrl + Enter,\\nExcel returns the object.',\n",
|
158 |
+
" 'start': 114.149,\n",
|
159 |
+
" 'duration': 4.111},\n",
|
160 |
+
" {'text': \"In this case, the 'describe' method returns\\na dataframe.\",\n",
|
161 |
+
" 'start': 118.26,\n",
|
162 |
+
" 'duration': 4.179},\n",
|
163 |
+
" {'text': 'If you actually want to print the dataframe\\nto Excel, you can select \"Excel value\" from',\n",
|
164 |
+
" 'start': 122.439,\n",
|
165 |
+
" 'duration': 4.47},\n",
|
166 |
+
" {'text': 'the drop-down list.', 'start': 126.909, 'duration': 1.081},\n",
|
167 |
+
" {'text': \"You'll then see a statistical summary of the\\ndata directly in Excel.\",\n",
|
168 |
+
" 'start': 127.99,\n",
|
169 |
+
" 'duration': 3.139},\n",
|
170 |
+
" {'text': 'Likewise, I will calculate the correlation.',\n",
|
171 |
+
" 'start': 131.129,\n",
|
172 |
+
" 'duration': 2.551},\n",
|
173 |
+
" {'text': \"But this time, instead of using my 'df' variable,\\nI will refer to the cell that holds the dataframe\",\n",
|
174 |
+
" 'start': 133.68,\n",
|
175 |
+
" 'duration': 5.3},\n",
|
176 |
+
" {'text': 'object, which is H2 in my case.',\n",
|
177 |
+
" 'start': 138.98,\n",
|
178 |
+
" 'duration': 2.36},\n",
|
179 |
+
" {'text': 'Then, on my dataframe object, I can call the\\ncorrelation method.',\n",
|
180 |
+
" 'start': 141.34,\n",
|
181 |
+
" 'duration': 4.47},\n",
|
182 |
+
" {'text': 'As before, we get a dataframe in return.',\n",
|
183 |
+
" 'start': 145.81,\n",
|
184 |
+
" 'duration': 2.44},\n",
|
185 |
+
" {'text': 'However, I will adjust the output to insert\\nthe data into the spreadsheet.',\n",
|
186 |
+
" 'start': 148.25,\n",
|
187 |
+
" 'duration': 4.709},\n",
|
188 |
+
" {'text': \"Okay, now let's proceed to some basic plots.\",\n",
|
189 |
+
" 'start': 152.959,\n",
|
190 |
+
" 'duration': 2.991},\n",
|
191 |
+
" {'text': 'With the integration of Python, we can tap\\ninto various plotting libraries.',\n",
|
192 |
+
" 'start': 155.95,\n",
|
193 |
+
" 'duration': 4.1},\n",
|
194 |
+
" {'text': 'For my demonstration, I will use matplotlib\\nto craft a scatter plot.',\n",
|
195 |
+
" 'start': 160.05,\n",
|
196 |
+
" 'duration': 4.24},\n",
|
197 |
+
" {'text': 'When I run the code, it returns an image object.',\n",
|
198 |
+
" 'start': 164.29,\n",
|
199 |
+
" 'duration': 2.75},\n",
|
200 |
+
" {'text': 'However, as with the earlier examples, I want\\nto display the actual chart.',\n",
|
201 |
+
" 'start': 167.04,\n",
|
202 |
+
" 'duration': 4.42},\n",
|
203 |
+
" {'text': 'So, I just need to switch the output.',\n",
|
204 |
+
" 'start': 171.46,\n",
|
205 |
+
" 'duration': 2.39},\n",
|
206 |
+
" {'text': 'As a result, we have an image stored in a\\ncell.',\n",
|
207 |
+
" 'start': 173.85,\n",
|
208 |
+
" 'duration': 3.71},\n",
|
209 |
+
" {'text': 'You can right-click on this image to create\\na reference to the cell.',\n",
|
210 |
+
" 'start': 177.56,\n",
|
211 |
+
" 'duration': 4.08},\n",
|
212 |
+
" {'text': 'And now, we have an Excel image with our scatter\\nplot.',\n",
|
213 |
+
" 'start': 181.64,\n",
|
214 |
+
" 'duration': 2.929},\n",
|
215 |
+
" {'text': 'Next, I plan to generate a Seaborn pair plot,\\nwhich only requires one line of code.',\n",
|
216 |
+
" 'start': 184.569,\n",
|
217 |
+
" 'duration': 6.14},\n",
|
218 |
+
" {'text': 'The execution of this cell might take a moment,\\nbut once complete, it also returns an image',\n",
|
219 |
+
" 'start': 190.709,\n",
|
220 |
+
" 'duration': 6.041},\n",
|
221 |
+
" {'text': 'object.', 'start': 196.75, 'duration': 1.0},\n",
|
222 |
+
" {'text': \"Similar to before, I'll create a reference\\nfor this image.\",\n",
|
223 |
+
" 'start': 197.75,\n",
|
224 |
+
" 'duration': 3.4},\n",
|
225 |
+
" {'text': 'And there we have it: our pair plot.',\n",
|
226 |
+
" 'start': 201.15,\n",
|
227 |
+
" 'duration': 2.41},\n",
|
228 |
+
" {'text': 'This is particularly useful for visualizing\\nthe linear correlation among all dataset variables',\n",
|
229 |
+
" 'start': 203.56,\n",
|
230 |
+
" 'duration': 4.87},\n",
|
231 |
+
" {'text': 'and displaying the distribution.',\n",
|
232 |
+
" 'start': 208.43,\n",
|
233 |
+
" 'duration': 2.51},\n",
|
234 |
+
" {'text': 'Lastly, I will generate a linear regression\\nplot for two distinct variables.',\n",
|
235 |
+
" 'start': 210.94,\n",
|
236 |
+
" 'duration': 4.94},\n",
|
237 |
+
" {'text': 'Once again, in Seaborn, we only need one line\\nof code for this.',\n",
|
238 |
+
" 'start': 215.88,\n",
|
239 |
+
" 'duration': 4.55},\n",
|
240 |
+
" {'text': 'Okay, so those were some basic examples that\\ngive some general idea of this new feature.',\n",
|
241 |
+
" 'start': 220.43,\n",
|
242 |
+
" 'duration': 5.699},\n",
|
243 |
+
" {'text': 'Now, let us move on to a real-world example.',\n",
|
244 |
+
" 'start': 226.129,\n",
|
245 |
+
" 'duration': 3.211},\n",
|
246 |
+
" {'text': 'Here in the datasheet, I have a transaction\\ntable of sales for five different stores in',\n",
|
247 |
+
" 'start': 229.34,\n",
|
248 |
+
" 'duration': 4.47},\n",
|
249 |
+
" {'text': 'Japan.', 'start': 233.81, 'duration': 1.0},\n",
|
250 |
+
" {'text': 'We have there the City where the store is\\nlocated, the information of the customer,',\n",
|
251 |
+
" 'start': 234.81,\n",
|
252 |
+
" 'duration': 3.709},\n",
|
253 |
+
" {'text': 'so, if the customer was a member or not and\\nthe gender of the customer.',\n",
|
254 |
+
" 'start': 238.519,\n",
|
255 |
+
" 'duration': 3.881},\n",
|
256 |
+
" {'text': 'Next, we have the information about the product\\nline, unit price, quantity, date and time',\n",
|
257 |
+
" 'start': 242.4,\n",
|
258 |
+
" 'duration': 5.39},\n",
|
259 |
+
" {'text': 'of the purchase, the payment method, the rating\\nfrom the customer and the sales amount, which',\n",
|
260 |
+
" 'start': 247.79,\n",
|
261 |
+
" 'duration': 5.49},\n",
|
262 |
+
" {'text': 'is the unit price multiplied by the quantity.',\n",
|
263 |
+
" 'start': 253.28,\n",
|
264 |
+
" 'duration': 2.769},\n",
|
265 |
+
" {'text': 'As before, this data is an Excel table; I\\nnamed it \"table Sales\".',\n",
|
266 |
+
" 'start': 256.049,\n",
|
267 |
+
" 'duration': 6.071},\n",
|
268 |
+
" {'text': \"Okay, now I've taken this data and conducted\\nsome analysis using Python.\",\n",
|
269 |
+
" 'start': 262.12,\n",
|
270 |
+
" 'duration': 5.269},\n",
|
271 |
+
" {'text': 'First, I loaded the dataframe and named it\\n\"data\".',\n",
|
272 |
+
" 'start': 267.389,\n",
|
273 |
+
" 'duration': 4.991},\n",
|
274 |
+
" {'text': \"After loading the data, there wasn't much\\ncleanup needed.\",\n",
|
275 |
+
" 'start': 272.38,\n",
|
276 |
+
" 'duration': 2.48},\n",
|
277 |
+
" {'text': 'The main task was converting the date and\\ntime column into a DateTime object, which',\n",
|
278 |
+
" 'start': 274.86,\n",
|
279 |
+
" 'duration': 5.16},\n",
|
280 |
+
" {'text': 'is required for my time and date-based analysis.',\n",
|
281 |
+
" 'start': 280.02,\n",
|
282 |
+
" 'duration': 3.05},\n",
|
283 |
+
" {'text': \"And there's also an important hint: the cleanup\\nprocess is in a cell below the actual dataframe.\",\n",
|
284 |
+
" 'start': 283.07,\n",
|
285 |
+
" 'duration': 6.31},\n",
|
286 |
+
" {'text': \"This is important because I refer to the 'data'\\nvariable, which should be defined in a cell\",\n",
|
287 |
+
" 'start': 289.38,\n",
|
288 |
+
" 'duration': 4.93},\n",
|
289 |
+
" {'text': 'above my current one, as the Python code is\\nvalidated from top to bottom and left to right.',\n",
|
290 |
+
" 'start': 294.31,\n",
|
291 |
+
" 'duration': 6.9},\n",
|
292 |
+
" {'text': 'With that said, let me show you my code that\\nreturns the top 5 selling products.',\n",
|
293 |
+
" 'start': 301.21,\n",
|
294 |
+
" 'duration': 4.22},\n",
|
295 |
+
" {'text': 'I grouped our dataframe by Product and, following\\nthat, specified the aggregation mode.',\n",
|
296 |
+
" 'start': 305.43,\n",
|
297 |
+
" 'duration': 5.04},\n",
|
298 |
+
" {'text': 'This next part is pretty cool; instead of\\nhardcoding the aggregation method, I linked',\n",
|
299 |
+
" 'start': 310.47,\n",
|
300 |
+
" 'duration': 5.789},\n",
|
301 |
+
" {'text': 'it to cell C7.', 'start': 316.259, 'duration': 1.341},\n",
|
302 |
+
" {'text': 'I named this cell \"Calc_Method\".',\n",
|
303 |
+
" 'start': 317.6,\n",
|
304 |
+
" 'duration': 2.37},\n",
|
305 |
+
" {'text': 'This is pretty neat because now you can combine\\nthe flexibility of Excel with Python.',\n",
|
306 |
+
" 'start': 319.97,\n",
|
307 |
+
" 'duration': 4.73},\n",
|
308 |
+
" {'text': 'So, before I linked it, I hardcoded the aggregation\\nmethod sum in my Pandas code.',\n",
|
309 |
+
" 'start': 324.7,\n",
|
310 |
+
" 'duration': 5.279},\n",
|
311 |
+
" {'text': 'I then inserted a drop-down menu and named\\nthe cell \"Calc_Method\".',\n",
|
312 |
+
" 'start': 329.979,\n",
|
313 |
+
" 'duration': 2.761},\n",
|
314 |
+
" {'text': 'And now, in the Python code, you could just\\ntype out the cell reference, or if you delete',\n",
|
315 |
+
" 'start': 332.74,\n",
|
316 |
+
" 'duration': 6.79},\n",
|
317 |
+
" {'text': 'it again, you could also just select the cell.',\n",
|
318 |
+
" 'start': 339.53,\n",
|
319 |
+
" 'duration': 3.28},\n",
|
320 |
+
" {'text': 'And when I execute the code, it is calculated\\ncorrectly.',\n",
|
321 |
+
" 'start': 342.81,\n",
|
322 |
+
" 'duration': 2.97},\n",
|
323 |
+
" {'text': 'Now, the cool part is that I just need to\\nchange this cell here, and then all my calculations',\n",
|
324 |
+
" 'start': 345.78,\n",
|
325 |
+
" 'duration': 5.67},\n",
|
326 |
+
" {'text': 'will show the average sales amount.',\n",
|
327 |
+
" 'start': 351.45,\n",
|
328 |
+
" 'duration': 2.38},\n",
|
329 |
+
" {'text': 'When I do this, you will also notice that\\nall my charts are also being updated.',\n",
|
330 |
+
" 'start': 353.83,\n",
|
331 |
+
" 'duration': 4.01},\n",
|
332 |
+
" {'text': 'In fact, if we look at my chart for the top\\n5 selling products, you will see that I have',\n",
|
333 |
+
" 'start': 357.84,\n",
|
334 |
+
" 'duration': 4.919},\n",
|
335 |
+
" {'text': 'done the same for the colours of the bars.',\n",
|
336 |
+
" 'start': 362.759,\n",
|
337 |
+
" 'duration': 2.561},\n",
|
338 |
+
" {'text': 'This is linked to the following cell.',\n",
|
339 |
+
" 'start': 365.32,\n",
|
340 |
+
" 'duration': 2.07},\n",
|
341 |
+
" {'text': \"Okay, I'll reduce the size of the formula\\nbar, and then from the drop-down menu, I'll\",\n",
|
342 |
+
" 'start': 367.39,\n",
|
343 |
+
" 'duration': 6.33},\n",
|
344 |
+
" {'text': 'select another colour.', 'start': 373.72, 'duration': 1.52},\n",
|
345 |
+
" {'text': 'Doing so will change the colours of the bars.',\n",
|
346 |
+
" 'start': 375.24,\n",
|
347 |
+
" 'duration': 3.57},\n",
|
348 |
+
" {'text': 'For the next analysis, I will group the sales\\nby weekday.',\n",
|
349 |
+
" 'start': 378.81,\n",
|
350 |
+
" 'duration': 3.37},\n",
|
351 |
+
" {'text': 'Doing this in Pandas is actually not too complicated.',\n",
|
352 |
+
" 'start': 382.18,\n",
|
353 |
+
" 'duration': 3.26},\n",
|
354 |
+
" {'text': \"On the dataframe, I'll create a new column\\nusing the assign method.\",\n",
|
355 |
+
" 'start': 385.44,\n",
|
356 |
+
" 'duration': 2.991},\n",
|
357 |
+
" {'text': \"The new column will be named 'weekday', and\\nI'll extract the weekday from the date column.\",\n",
|
358 |
+
" 'start': 388.431,\n",
|
359 |
+
" 'duration': 5.208},\n",
|
360 |
+
" {'text': \"I'll then group the data by this new column,\\naggregate the sales, and rename and reset\",\n",
|
361 |
+
" 'start': 393.639,\n",
|
362 |
+
" 'duration': 5.351},\n",
|
363 |
+
" {'text': 'the index.', 'start': 398.99, 'duration': 1.36},\n",
|
364 |
+
" {'text': \"And another quick note here: I'm using a lot\\nof pandas steps one after the other.\",\n",
|
365 |
+
" 'start': 400.35,\n",
|
366 |
+
" 'duration': 4.1},\n",
|
367 |
+
" {'text': 'I think it makes the code easy to read.',\n",
|
368 |
+
" 'start': 404.45,\n",
|
369 |
+
" 'duration': 2.29},\n",
|
370 |
+
" {'text': 'But if you like, you can do each step one\\nat a time.',\n",
|
371 |
+
" 'start': 406.74,\n",
|
372 |
+
" 'duration': 4.221},\n",
|
373 |
+
" {'text': 'However, if you want to learn more about chaining\\ndifferent pandas methods, I suggest my following',\n",
|
374 |
+
" 'start': 410.961,\n",
|
375 |
+
" 'duration': 3.999},\n",
|
376 |
+
" {'text': 'video.', 'start': 414.96, 'duration': 1.0},\n",
|
377 |
+
" {'text': 'In that video, I will walk you through how\\nchain pandas methods and also explain why',\n",
|
378 |
+
" 'start': 415.96,\n",
|
379 |
+
" 'duration': 4.09},\n",
|
380 |
+
" {'text': 'you might want to use that approach.',\n",
|
381 |
+
" 'start': 420.05,\n",
|
382 |
+
" 'duration': 1.89},\n",
|
383 |
+
" {'text': \"I've put the link to that video in the info\\ncard above and in the description below.\",\n",
|
384 |
+
" 'start': 421.94,\n",
|
385 |
+
" 'duration': 4.17},\n",
|
386 |
+
" {'text': 'Okay, so now that we have the sales grouped\\nby weekday, we can also plot it.',\n",
|
387 |
+
" 'start': 426.11,\n",
|
388 |
+
" 'duration': 4.929},\n",
|
389 |
+
" {'text': 'For this, I wrote the code next to the table.',\n",
|
390 |
+
" 'start': 431.039,\n",
|
391 |
+
" 'duration': 2.75},\n",
|
392 |
+
" {'text': \"And here is also a fun fact: I didn't write\\nall the code myself; I got help from ChatGPT.\",\n",
|
393 |
+
" 'start': 433.789,\n",
|
394 |
+
" 'duration': 5.331},\n",
|
395 |
+
" {'text': 'OK, next up, I calculated sales by the hour.',\n",
|
396 |
+
" 'start': 439.12,\n",
|
397 |
+
" 'duration': 3.72},\n",
|
398 |
+
" {'text': 'Again, not much pandas code is needed for\\nthis type of calculation.',\n",
|
399 |
+
" 'start': 442.84,\n",
|
400 |
+
" 'duration': 4.25},\n",
|
401 |
+
" {'text': 'And if we look at the chart, most customers\\nseem to do their shopping after work, especially',\n",
|
402 |
+
" 'start': 447.09,\n",
|
403 |
+
" 'duration': 4.561},\n",
|
404 |
+
" {'text': 'from 7 pm onwards.', 'start': 451.651, 'duration': 1.529},\n",
|
405 |
+
" {'text': 'So, during these peak hours, we might need\\nadditional staff and cashiers.',\n",
|
406 |
+
" 'start': 453.18,\n",
|
407 |
+
" 'duration': 4.6},\n",
|
408 |
+
" {'text': \"With that insight, let's move on to the next\\nanalysis.\",\n",
|
409 |
+
" 'start': 457.78,\n",
|
410 |
+
" 'duration': 2.44},\n",
|
411 |
+
" {'text': 'Here, I utilized the pandas method \"percentage\\nchange\" to calculate the month-over-month',\n",
|
412 |
+
" 'start': 460.22,\n",
|
413 |
+
" 'duration': 5.06},\n",
|
414 |
+
" {'text': 'growth rate.', 'start': 465.28, 'duration': 1.46},\n",
|
415 |
+
" {'text': 'I then again asked ChatGPT to provide me with\\nthe code to plot the sales amount by month',\n",
|
416 |
+
" 'start': 466.74,\n",
|
417 |
+
" 'duration': 5.03},\n",
|
418 |
+
" {'text': 'and, on the secondary axis, the growth rate.',\n",
|
419 |
+
" 'start': 471.77,\n",
|
420 |
+
" 'duration': 2.81},\n",
|
421 |
+
" {'text': 'And as a result, I have got back the following\\nchart.',\n",
|
422 |
+
" 'start': 474.58,\n",
|
423 |
+
" 'duration': 3.679},\n",
|
424 |
+
" {'text': 'Frankly speaking, I think using native Excel\\ncharts would have been quicker for this purpose.',\n",
|
425 |
+
" 'start': 478.259,\n",
|
426 |
+
" 'duration': 4.861},\n",
|
427 |
+
" {'text': 'Also, all the charts I chose here are fairly\\nbasic.',\n",
|
428 |
+
" 'start': 483.12,\n",
|
429 |
+
" 'duration': 3.139},\n",
|
430 |
+
" {'text': \"There's really no need to overcomplicate things\\nby using Python for this.\",\n",
|
431 |
+
" 'start': 486.259,\n",
|
432 |
+
" 'duration': 4.071},\n",
|
433 |
+
" {'text': 'However, I will also demonstrate a scenario\\nwhere you might want to use a Python chart.',\n",
|
434 |
+
" 'start': 490.33,\n",
|
435 |
+
" 'duration': 5.96},\n",
|
436 |
+
" {'text': 'For the following heatmap, I created a pivot\\ntable using pandas to display the sales amount',\n",
|
437 |
+
" 'start': 496.29,\n",
|
438 |
+
" 'duration': 5.379},\n",
|
439 |
+
" {'text': 'by product line and month.', 'start': 501.669, 'duration': 1.74},\n",
|
440 |
+
" {'text': 'I then plotted this new dataframe with a Seaborn\\nheatmap.',\n",
|
441 |
+
" 'start': 503.409,\n",
|
442 |
+
" 'duration': 3.711},\n",
|
443 |
+
" {'text': 'The resulting chart has a colour scale: the\\ndarker the colour, the higher the sales.',\n",
|
444 |
+
" 'start': 507.12,\n",
|
445 |
+
" 'duration': 4.68},\n",
|
446 |
+
" {'text': 'The y-axis represents the months, while the\\nx-axis displays the different product lines.',\n",
|
447 |
+
" 'start': 511.8,\n",
|
448 |
+
" 'duration': 5.919},\n",
|
449 |
+
" {'text': 'And from this heatmap, we can see, that sales\\nfor groceries remain relatively consistent',\n",
|
450 |
+
" 'start': 517.719,\n",
|
451 |
+
" 'duration': 4.661},\n",
|
452 |
+
" {'text': 'throughout the year, which is kind of expected.',\n",
|
453 |
+
" 'start': 522.38,\n",
|
454 |
+
" 'duration': 3.31},\n",
|
455 |
+
" {'text': 'However, for the Electronics, we will notice\\nhigher sales in a specific month.',\n",
|
456 |
+
" 'start': 525.69,\n",
|
457 |
+
" 'duration': 3.769},\n",
|
458 |
+
" {'text': 'So, we might want to dig deeper into these\\ninsights.',\n",
|
459 |
+
" 'start': 529.459,\n",
|
460 |
+
" 'duration': 3.07},\n",
|
461 |
+
" {'text': 'So, this is just one example of a more advanced\\nchart that would be difficult to replicate',\n",
|
462 |
+
" 'start': 532.529,\n",
|
463 |
+
" 'duration': 5.071},\n",
|
464 |
+
" {'text': 'in Excel.', 'start': 537.6, 'duration': 1.1},\n",
|
465 |
+
" {'text': \"Obviously, you shouldn't just pick a chart\\nbecause it looks fancy.\",\n",
|
466 |
+
" 'start': 538.7,\n",
|
467 |
+
" 'duration': 3.92},\n",
|
468 |
+
" {'text': 'It should simply convey the message of your\\ninsights.',\n",
|
469 |
+
" 'start': 542.62,\n",
|
470 |
+
" 'duration': 3.43},\n",
|
471 |
+
" {'text': \"Now that you've seen some potential use cases\\nlet me share my thoughts about running Python\",\n",
|
472 |
+
" 'start': 546.05,\n",
|
473 |
+
" 'duration': 4.4},\n",
|
474 |
+
" {'text': 'code in Excel.', 'start': 550.45, 'duration': 1.04},\n",
|
475 |
+
" {'text': \"In general, I think, it's fantastic that you\\ncan now integrate Python with Excel.\",\n",
|
476 |
+
" 'start': 551.49,\n",
|
477 |
+
" 'duration': 3.86},\n",
|
478 |
+
" {'text': 'This just adds another tool to your toolbox.',\n",
|
479 |
+
" 'start': 555.35,\n",
|
480 |
+
" 'duration': 3.21},\n",
|
481 |
+
" {'text': 'Especially when dealing with dates and times,\\ncertain calculations are much more straightforward',\n",
|
482 |
+
" 'start': 558.56,\n",
|
483 |
+
" 'duration': 4.019},\n",
|
484 |
+
" {'text': 'in pandas, at least in my opinion.',\n",
|
485 |
+
" 'start': 562.579,\n",
|
486 |
+
" 'duration': 2.611},\n",
|
487 |
+
" {'text': 'However, Excel also offers another powerful\\ntool for data cleaning and aggregation: PowerQuery.',\n",
|
488 |
+
" 'start': 565.19,\n",
|
489 |
+
" 'duration': 5.9},\n",
|
490 |
+
" {'text': \"If you've worked with PowerQuery before, you'll\\nknow its capabilities.\",\n",
|
491 |
+
" 'start': 571.09,\n",
|
492 |
+
" 'duration': 4.27},\n",
|
493 |
+
" {'text': \"Also, even though I'm not a beginner with\\npandas, I often need to test my code and tinker\",\n",
|
494 |
+
" 'start': 575.36,\n",
|
495 |
+
" 'duration': 5.37},\n",
|
496 |
+
" {'text': 'around with it.', 'start': 580.73, 'duration': 1.29},\n",
|
497 |
+
" {'text': \"And I've noticed that the more Python calculations\\nyou have in your spreadsheet, the slower the\",\n",
|
498 |
+
" 'start': 582.02,\n",
|
499 |
+
" 'duration': 5.059},\n",
|
500 |
+
" {'text': 'calculation becomes.', 'start': 587.079, 'duration': 1.311},\n",
|
501 |
+
" {'text': 'So, I find it rather clunky to do my exploratory\\ndata analysis directly in Excel.',\n",
|
502 |
+
" 'start': 588.39,\n",
|
503 |
+
" 'duration': 5.79},\n",
|
504 |
+
" {'text': \"Instead, I've been turning to a Jupyter Notebook.\",\n",
|
505 |
+
" 'start': 594.18,\n",
|
506 |
+
" 'duration': 3.0},\n",
|
507 |
+
" {'text': 'Once I tested my code in a Jupyter Notebook,\\nI plugged it into Excel.',\n",
|
508 |
+
" 'start': 597.18,\n",
|
509 |
+
" 'duration': 4.27},\n",
|
510 |
+
" {'text': 'Now, to quickly get the Excel data into a\\nJupyter Notebook, I created my own add-in,',\n",
|
511 |
+
" 'start': 601.45,\n",
|
512 |
+
" 'duration': 5.11},\n",
|
513 |
+
" {'text': 'which is called \"MyToolBelt\".', 'start': 606.56, 'duration': 1.0},\n",
|
514 |
+
" {'text': 'With it, I just click a button, select the\\ncell range I want to analyze, provide a title',\n",
|
515 |
+
" 'start': 607.56,\n",
|
516 |
+
" 'duration': 6.26},\n",
|
517 |
+
" {'text': \"if I wish, and then hit 'OK'.\", 'start': 613.82, 'duration': 2.66},\n",
|
518 |
+
" {'text': \"This action generates a new Jupyter Notebook\\nin my workbook's directory.\",\n",
|
519 |
+
" 'start': 616.48,\n",
|
520 |
+
" 'duration': 3.19},\n",
|
521 |
+
" {'text': 'When I open it, I have my title, library imports,\\nand the respective code to load the Excel',\n",
|
522 |
+
" 'start': 619.67,\n",
|
523 |
+
" 'duration': 6.94},\n",
|
524 |
+
" {'text': 'data as a pandas dataframe – with the correct\\npath to the spreadsheet, sheet name, columns,',\n",
|
525 |
+
" 'start': 626.61,\n",
|
526 |
+
" 'duration': 5.56},\n",
|
527 |
+
" {'text': 'and row count.', 'start': 632.17, 'duration': 1.05},\n",
|
528 |
+
" {'text': 'So, with this add-in, I can speed up my analysis,\\nand now I also have a clear separation between',\n",
|
529 |
+
" 'start': 633.22,\n",
|
530 |
+
" 'duration': 5.14},\n",
|
531 |
+
" {'text': 'my data and the code I write.', 'start': 638.36, 'duration': 2.86},\n",
|
532 |
+
" {'text': \"If you also want to install the add-in, I'll\\ndrop a link in the description below.\",\n",
|
533 |
+
" 'start': 641.22,\n",
|
534 |
+
" 'duration': 3.66},\n",
|
535 |
+
" {'text': \"However, it's worth noting that the Jupyter\\nNotebook feature is only available in the\",\n",
|
536 |
+
" 'start': 644.88,\n",
|
537 |
+
" 'duration': 4.26},\n",
|
538 |
+
" {'text': 'paid version.', 'start': 649.14, 'duration': 1.0},\n",
|
539 |
+
" {'text': \"Now, let's get back to native Python functionality\\nin Excel.\",\n",
|
540 |
+
" 'start': 650.14,\n",
|
541 |
+
" 'duration': 4.28},\n",
|
542 |
+
" {'text': 'In this video, I showcased examples using\\npandas, matplotlib, and seaborn.',\n",
|
543 |
+
" 'start': 654.42,\n",
|
544 |
+
" 'duration': 4.52},\n",
|
545 |
+
" {'text': 'However, you can also access additional packages\\navailable in the Anaconda distribution, like',\n",
|
546 |
+
" 'start': 658.94,\n",
|
547 |
+
" 'duration': 5.8},\n",
|
548 |
+
" {'text': 'statsmodels, scipy, and scikit-learn.',\n",
|
549 |
+
" 'start': 664.74,\n",
|
550 |
+
" 'duration': 2.31},\n",
|
551 |
+
" {'text': 'By default, many of these packages are directly\\nloaded when initializing the environment.',\n",
|
552 |
+
" 'start': 667.05,\n",
|
553 |
+
" 'duration': 5.339},\n",
|
554 |
+
" {'text': \"That's why, in my example, I didn't need to\\nimport the libraries separately.\",\n",
|
555 |
+
" 'start': 672.389,\n",
|
556 |
+
" 'duration': 4.88},\n",
|
557 |
+
" {'text': 'So, in my upcoming videos, I also want to\\nexplore the possibilities of using basic machine',\n",
|
558 |
+
" 'start': 677.269,\n",
|
559 |
+
" 'duration': 5.161},\n",
|
560 |
+
" {'text': 'learning with scikit-learn directly in Excel.',\n",
|
561 |
+
" 'start': 682.43,\n",
|
562 |
+
" 'duration': 3.19},\n",
|
563 |
+
" {'text': \"Because those types of calculations can't\\nbe done with PowerQuery.\",\n",
|
564 |
+
" 'start': 685.62,\n",
|
565 |
+
" 'duration': 3.82},\n",
|
566 |
+
" {'text': 'And speaking of PowerQuery, you can actually\\nalso connect Python to your PowerQuery tables,',\n",
|
567 |
+
" 'start': 689.44,\n",
|
568 |
+
" 'duration': 5.57},\n",
|
569 |
+
" {'text': \"something I haven't shown in this video.\",\n",
|
570 |
+
" 'start': 695.01,\n",
|
571 |
+
" 'duration': 1.699},\n",
|
572 |
+
" {'text': 'Lastly, before you go, let me highlight some\\nlimitations.',\n",
|
573 |
+
" 'start': 696.709,\n",
|
574 |
+
" 'duration': 3.781},\n",
|
575 |
+
" {'text': \"As of now, animated Python charts like those\\nfrom Plotly aren't supported.\",\n",
|
576 |
+
" 'start': 700.49,\n",
|
577 |
+
" 'duration': 4.99},\n",
|
578 |
+
" {'text': 'Also, the Python functionality is currently\\nexclusive to Excel Desktop 365 Beta Channel',\n",
|
579 |
+
" 'start': 705.48,\n",
|
580 |
+
" 'duration': 6.67},\n",
|
581 |
+
" {'text': 'users, and it only works on Windows at the\\nmoment.',\n",
|
582 |
+
" 'start': 712.15,\n",
|
583 |
+
" 'duration': 3.52},\n",
|
584 |
+
" {'text': 'Another constraint is that you cannot connect\\nto external files using Python; so, if you',\n",
|
585 |
+
" 'start': 715.67,\n",
|
586 |
+
" 'duration': 5.469},\n",
|
587 |
+
" {'text': \"want to connect to other files and folders,\\nyou'd need to use PowerQuery.\",\n",
|
588 |
+
" 'start': 721.139,\n",
|
589 |
+
" 'duration': 4.82},\n",
|
590 |
+
" {'text': 'Moreover, only the libraries supported by\\nAnaconda are available for use.',\n",
|
591 |
+
" 'start': 725.959,\n",
|
592 |
+
" 'duration': 4.861},\n",
|
593 |
+
" {'text': \"So, if there's a 3rd party package that isn't\\npart of the Anaconda distribution, you won't\",\n",
|
594 |
+
" 'start': 730.82,\n",
|
595 |
+
" 'duration': 5.11},\n",
|
596 |
+
" {'text': 'be able to use it.', 'start': 735.93, 'duration': 1.77},\n",
|
597 |
+
" {'text': \"With that said, I'd love to hear your thoughts\\non this new functionality.\",\n",
|
598 |
+
" 'start': 737.7,\n",
|
599 |
+
" 'duration': 2.87},\n",
|
600 |
+
" {'text': 'Please share them in the comments below.',\n",
|
601 |
+
" 'start': 740.57,\n",
|
602 |
+
" 'duration': 1.87},\n",
|
603 |
+
" {'text': \"And as always, thanks for watching, and I'll\\nsee you in the next video.\",\n",
|
604 |
+
" 'start': 742.44,\n",
|
605 |
+
" 'duration': 20.29}]"
|
606 |
+
]
|
607 |
+
},
|
608 |
+
"execution_count": 2,
|
609 |
+
"metadata": {},
|
610 |
+
"output_type": "execute_result"
|
611 |
+
}
|
612 |
+
],
|
613 |
+
"source": [
|
614 |
+
"from youtube_transcript_api import YouTubeTranscriptApi\n",
|
615 |
+
"video_id = \"bcYwiwsDfGE\"\n",
|
616 |
+
"transcript = YouTubeTranscriptApi.get_transcript(video_id)\n",
|
617 |
+
"transcript"
|
618 |
+
]
|
619 |
+
},
|
620 |
+
{
|
621 |
+
"cell_type": "code",
|
622 |
+
"execution_count": 3,
|
623 |
+
"id": "baeae965",
|
624 |
+
"metadata": {},
|
625 |
+
"outputs": [
|
626 |
+
{
|
627 |
+
"data": {
|
628 |
+
"text/plain": [
|
629 |
+
"'Okay, some of you might have heard already,\\nbut you can now use Python inside Excel. In this video, I will show some basic examples\\nof how to use it, and I\\'ll guide you through a real-world example to give you an idea of\\nthe possibilities. In that example, I\\'ll show you some very useful\\npandas features and some more advanced charts. Towards the end, I\\'ll also share my personal\\nopinion about this new feature and point out some limitations. But, before we start, a quick shout-out to\\nLuke. Luke was kind enough to connect me with people\\nfrom Anaconda so that I could test this feature. So, thank you very much, Luke and the team\\nfrom Anaconda. And with that said, let\\'s dive in. Ok, let\\'s start with a basic example. Under the formulas ribbon, there\\'s a new Python\\nsection. When I click on the Python logo, you\\'ll notice\\nthat the appearance of the formula bar changes. This is where you can now write your Python\\ncode. For the first step, I\\'ll create a dataframe\\nwith the command \"df is equal to\", and then simply select my Excel table here on the left. It doesn\\'t have to be a table, by the way;\\na normal cell range will also work. To execute the code, I will press Ctrl + Enter. If you just press Enter, it will insert a\\nnew line. So now, the data source is now your table. In my case, the table is named IrisDataSet,\\nand as it is correctly recognized, it has a header row. In the cell where I wrote the Python code,\\nthe dataframe object now appears. So, as you might already know, everything\\nin Python is an object, and we can store that object in a cell. I can also get a preview of what the dataframe\\nlooks like when I click on the icon. It gives me a preview of the dataframe. Now that we have our dataframe, you can use\\nall the different Pandas functions. I named my dataframe \\'df\\', so in the next\\ncell, I just need to type \\'df\\'. And for this example, I will use the \\'describe\\'\\nmethod to get some statistical insights into the data. When I execute the cell using Ctrl + Enter,\\nExcel returns the object. In this case, the \\'describe\\' method returns\\na dataframe. If you actually want to print the dataframe\\nto Excel, you can select \"Excel value\" from the drop-down list. You\\'ll then see a statistical summary of the\\ndata directly in Excel. Likewise, I will calculate the correlation. But this time, instead of using my \\'df\\' variable,\\nI will refer to the cell that holds the dataframe object, which is H2 in my case. Then, on my dataframe object, I can call the\\ncorrelation method. As before, we get a dataframe in return. However, I will adjust the output to insert\\nthe data into the spreadsheet. Okay, now let\\'s proceed to some basic plots. With the integration of Python, we can tap\\ninto various plotting libraries. For my demonstration, I will use matplotlib\\nto craft a scatter plot. When I run the code, it returns an image object. However, as with the earlier examples, I want\\nto display the actual chart. So, I just need to switch the output. As a result, we have an image stored in a\\ncell. You can right-click on this image to create\\na reference to the cell. And now, we have an Excel image with our scatter\\nplot. Next, I plan to generate a Seaborn pair plot,\\nwhich only requires one line of code. The execution of this cell might take a moment,\\nbut once complete, it also returns an image object. Similar to before, I\\'ll create a reference\\nfor this image. And there we have it: our pair plot. This is particularly useful for visualizing\\nthe linear correlation among all dataset variables and displaying the distribution. Lastly, I will generate a linear regression\\nplot for two distinct variables. Once again, in Seaborn, we only need one line\\nof code for this. Okay, so those were some basic examples that\\ngive some general idea of this new feature. Now, let us move on to a real-world example. Here in the datasheet, I have a transaction\\ntable of sales for five different stores in Japan. We have there the City where the store is\\nlocated, the information of the customer, so, if the customer was a member or not and\\nthe gender of the customer. Next, we have the information about the product\\nline, unit price, quantity, date and time of the purchase, the payment method, the rating\\nfrom the customer and the sales amount, which is the unit price multiplied by the quantity. As before, this data is an Excel table; I\\nnamed it \"table Sales\". Okay, now I\\'ve taken this data and conducted\\nsome analysis using Python. First, I loaded the dataframe and named it\\n\"data\". After loading the data, there wasn\\'t much\\ncleanup needed. The main task was converting the date and\\ntime column into a DateTime object, which is required for my time and date-based analysis. And there\\'s also an important hint: the cleanup\\nprocess is in a cell below the actual dataframe. This is important because I refer to the \\'data\\'\\nvariable, which should be defined in a cell above my current one, as the Python code is\\nvalidated from top to bottom and left to right. With that said, let me show you my code that\\nreturns the top 5 selling products. I grouped our dataframe by Product and, following\\nthat, specified the aggregation mode. This next part is pretty cool; instead of\\nhardcoding the aggregation method, I linked it to cell C7. I named this cell \"Calc_Method\". This is pretty neat because now you can combine\\nthe flexibility of Excel with Python. So, before I linked it, I hardcoded the aggregation\\nmethod sum in my Pandas code. I then inserted a drop-down menu and named\\nthe cell \"Calc_Method\". And now, in the Python code, you could just\\ntype out the cell reference, or if you delete it again, you could also just select the cell. And when I execute the code, it is calculated\\ncorrectly. Now, the cool part is that I just need to\\nchange this cell here, and then all my calculations will show the average sales amount. When I do this, you will also notice that\\nall my charts are also being updated. In fact, if we look at my chart for the top\\n5 selling products, you will see that I have done the same for the colours of the bars. This is linked to the following cell. Okay, I\\'ll reduce the size of the formula\\nbar, and then from the drop-down menu, I\\'ll select another colour. Doing so will change the colours of the bars. For the next analysis, I will group the sales\\nby weekday. Doing this in Pandas is actually not too complicated. On the dataframe, I\\'ll create a new column\\nusing the assign method. The new column will be named \\'weekday\\', and\\nI\\'ll extract the weekday from the date column. I\\'ll then group the data by this new column,\\naggregate the sales, and rename and reset the index. And another quick note here: I\\'m using a lot\\nof pandas steps one after the other. I think it makes the code easy to read. But if you like, you can do each step one\\nat a time. However, if you want to learn more about chaining\\ndifferent pandas methods, I suggest my following video. In that video, I will walk you through how\\nchain pandas methods and also explain why you might want to use that approach. I\\'ve put the link to that video in the info\\ncard above and in the description below. Okay, so now that we have the sales grouped\\nby weekday, we can also plot it. For this, I wrote the code next to the table. And here is also a fun fact: I didn\\'t write\\nall the code myself; I got help from ChatGPT. OK, next up, I calculated sales by the hour. Again, not much pandas code is needed for\\nthis type of calculation. And if we look at the chart, most customers\\nseem to do their shopping after work, especially from 7 pm onwards. So, during these peak hours, we might need\\nadditional staff and cashiers. With that insight, let\\'s move on to the next\\nanalysis. Here, I utilized the pandas method \"percentage\\nchange\" to calculate the month-over-month growth rate. I then again asked ChatGPT to provide me with\\nthe code to plot the sales amount by month and, on the secondary axis, the growth rate. And as a result, I have got back the following\\nchart. Frankly speaking, I think using native Excel\\ncharts would have been quicker for this purpose. Also, all the charts I chose here are fairly\\nbasic. There\\'s really no need to overcomplicate things\\nby using Python for this. However, I will also demonstrate a scenario\\nwhere you might want to use a Python chart. For the following heatmap, I created a pivot\\ntable using pandas to display the sales amount by product line and month. I then plotted this new dataframe with a Seaborn\\nheatmap. The resulting chart has a colour scale: the\\ndarker the colour, the higher the sales. The y-axis represents the months, while the\\nx-axis displays the different product lines. And from this heatmap, we can see, that sales\\nfor groceries remain relatively consistent throughout the year, which is kind of expected. However, for the Electronics, we will notice\\nhigher sales in a specific month. So, we might want to dig deeper into these\\ninsights. So, this is just one example of a more advanced\\nchart that would be difficult to replicate in Excel. Obviously, you shouldn\\'t just pick a chart\\nbecause it looks fancy. It should simply convey the message of your\\ninsights. Now that you\\'ve seen some potential use cases\\nlet me share my thoughts about running Python code in Excel. In general, I think, it\\'s fantastic that you\\ncan now integrate Python with Excel. This just adds another tool to your toolbox. Especially when dealing with dates and times,\\ncertain calculations are much more straightforward in pandas, at least in my opinion. However, Excel also offers another powerful\\ntool for data cleaning and aggregation: PowerQuery. If you\\'ve worked with PowerQuery before, you\\'ll\\nknow its capabilities. Also, even though I\\'m not a beginner with\\npandas, I often need to test my code and tinker around with it. And I\\'ve noticed that the more Python calculations\\nyou have in your spreadsheet, the slower the calculation becomes. So, I find it rather clunky to do my exploratory\\ndata analysis directly in Excel. Instead, I\\'ve been turning to a Jupyter Notebook. Once I tested my code in a Jupyter Notebook,\\nI plugged it into Excel. Now, to quickly get the Excel data into a\\nJupyter Notebook, I created my own add-in, which is called \"MyToolBelt\". With it, I just click a button, select the\\ncell range I want to analyze, provide a title if I wish, and then hit \\'OK\\'. This action generates a new Jupyter Notebook\\nin my workbook\\'s directory. When I open it, I have my title, library imports,\\nand the respective code to load the Excel data as a pandas dataframe – with the correct\\npath to the spreadsheet, sheet name, columns, and row count. So, with this add-in, I can speed up my analysis,\\nand now I also have a clear separation between my data and the code I write. If you also want to install the add-in, I\\'ll\\ndrop a link in the description below. However, it\\'s worth noting that the Jupyter\\nNotebook feature is only available in the paid version. Now, let\\'s get back to native Python functionality\\nin Excel. In this video, I showcased examples using\\npandas, matplotlib, and seaborn. However, you can also access additional packages\\navailable in the Anaconda distribution, like statsmodels, scipy, and scikit-learn. By default, many of these packages are directly\\nloaded when initializing the environment. That\\'s why, in my example, I didn\\'t need to\\nimport the libraries separately. So, in my upcoming videos, I also want to\\nexplore the possibilities of using basic machine learning with scikit-learn directly in Excel. Because those types of calculations can\\'t\\nbe done with PowerQuery. And speaking of PowerQuery, you can actually\\nalso connect Python to your PowerQuery tables, something I haven\\'t shown in this video. Lastly, before you go, let me highlight some\\nlimitations. As of now, animated Python charts like those\\nfrom Plotly aren\\'t supported. Also, the Python functionality is currently\\nexclusive to Excel Desktop 365 Beta Channel users, and it only works on Windows at the\\nmoment. Another constraint is that you cannot connect\\nto external files using Python; so, if you want to connect to other files and folders,\\nyou\\'d need to use PowerQuery. Moreover, only the libraries supported by\\nAnaconda are available for use. So, if there\\'s a 3rd party package that isn\\'t\\npart of the Anaconda distribution, you won\\'t be able to use it. With that said, I\\'d love to hear your thoughts\\non this new functionality. Please share them in the comments below. And as always, thanks for watching, and I\\'ll\\nsee you in the next video.'"
|
630 |
+
]
|
631 |
+
},
|
632 |
+
"execution_count": 3,
|
633 |
+
"metadata": {},
|
634 |
+
"output_type": "execute_result"
|
635 |
+
}
|
636 |
+
],
|
637 |
+
"source": [
|
638 |
+
"transcript = \" \".join([item[\"text\"] for item in transcript])\n",
|
639 |
+
"transcript"
|
640 |
+
]
|
641 |
+
},
|
642 |
+
{
|
643 |
+
"cell_type": "code",
|
644 |
+
"execution_count": null,
|
645 |
+
"id": "0b44040c",
|
646 |
+
"metadata": {},
|
647 |
+
"outputs": [],
|
648 |
+
"source": []
|
649 |
+
},
|
650 |
+
{
|
651 |
+
"cell_type": "markdown",
|
652 |
+
"id": "29bb8efa",
|
653 |
+
"metadata": {},
|
654 |
+
"source": [
|
655 |
+
"## 3. Feed video captions into LLM (OpenAI)"
|
656 |
+
]
|
657 |
+
},
|
658 |
+
{
|
659 |
+
"cell_type": "code",
|
660 |
+
"execution_count": 4,
|
661 |
+
"id": "ad82f2d3",
|
662 |
+
"metadata": {},
|
663 |
+
"outputs": [
|
664 |
+
{
|
665 |
+
"name": "stdout",
|
666 |
+
"output_type": "stream",
|
667 |
+
"text": [
|
668 |
+
"<class 'str'>\n",
|
669 |
+
"[\n",
|
670 |
+
" [\"What is the purpose of the video?\", \"To demonstrate how to use Python inside Excel\", \"To explain the limitations of using Python in Excel\", \"To showcase different data visualization libraries\"],\n",
|
671 |
+
" [\"What is the advantage of using pandas in Python?\", \"It makes certain calculations with dates and times easier\", \"It allows for the creation of fancy charts\", \"It speeds up the calculation process in Excel\"],\n",
|
672 |
+
" [\"How can you display a statistical summary of a dataframe in Excel?\", \"By selecting 'Excel value' from the drop-down list\", \"By clicking on the preview icon\", \"By right-clicking on the dataframe object\"],\n",
|
673 |
+
" [\"What is the purpose of the 'Calc_Method' cell?\", \"To specify the aggregation method for the top 5 selling products\", \"To determine the color scheme for the charts\", \"To calculate the month-over-month growth rate\"],\n",
|
674 |
+
" [\"What are some limitations of using Python in Excel?\", \"Animated charts and external file connections are not supported\", \"It only works on Windows and with Excel Desktop 365 Beta Channel\", \"Only libraries supported by Anaconda can be used\"]\n",
|
675 |
+
"]\n"
|
676 |
+
]
|
677 |
+
}
|
678 |
+
],
|
679 |
+
"source": [
|
680 |
+
"from langchain.chat_models import ChatOpenAI\n",
|
681 |
+
"from langchain.prompts.chat import ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate\n",
|
682 |
+
"from langchain.chains import LLMChain\n",
|
683 |
+
"\n",
|
684 |
+
"#########################################\n",
|
685 |
+
"OPENAI_API_KEY = \"sk-XXXXXXXXXXXXXXXXXXXXXXXX\"\n",
|
686 |
+
"#########################################\n",
|
687 |
+
"\n",
|
688 |
+
"\n",
|
689 |
+
"template = f\"\"\"\n",
|
690 |
+
"You are a helpful assistant programmed to generate questions based on any text provided. For every chunk of text you receive, you're tasked with designing 5 distinct questions. Each of these questions will be accompanied by 3 possible answers: one correct answer and two incorrect ones. \n",
|
691 |
+
"\n",
|
692 |
+
"For clarity and ease of processing, structure your response in a way that emulates a Python list of lists. \n",
|
693 |
+
"\n",
|
694 |
+
"Your output should be shaped as follows:\n",
|
695 |
+
"\n",
|
696 |
+
"1. An outer list that contains 5 inner lists.\n",
|
697 |
+
"2. Each inner list represents a set of question and answers, and contains exactly 4 strings in this order:\n",
|
698 |
+
"- The generated question.\n",
|
699 |
+
"- The correct answer.\n",
|
700 |
+
"- The first incorrect answer.\n",
|
701 |
+
"- The second incorrect answer.\n",
|
702 |
+
"\n",
|
703 |
+
"Your output should mirror this structure:\n",
|
704 |
+
"[\n",
|
705 |
+
" [\"Generated Question 1\", \"Correct Answer 1\", \"Incorrect Answer 1.1\", \"Incorrect Answer 1.2\"],\n",
|
706 |
+
" [\"Generated Question 2\", \"Correct Answer 2\", \"Incorrect Answer 2.1\", \"Incorrect Answer 2.2\"],\n",
|
707 |
+
" ...\n",
|
708 |
+
"]\n",
|
709 |
+
"\n",
|
710 |
+
"It is crucial that you adhere to this format as it's optimized for further Python processing.\n",
|
711 |
+
"\n",
|
712 |
+
"\"\"\"\n",
|
713 |
+
"\n",
|
714 |
+
"system_message_prompt = SystemMessagePromptTemplate.from_template(template)\n",
|
715 |
+
"human_message_prompt = HumanMessagePromptTemplate.from_template(\"{text}\")\n",
|
716 |
+
"chat_prompt = ChatPromptTemplate.from_messages(\n",
|
717 |
+
" [system_message_prompt, human_message_prompt]\n",
|
718 |
+
")\n",
|
719 |
+
"chain = LLMChain(\n",
|
720 |
+
" llm=ChatOpenAI(openai_api_key=OPENAI_API_KEY),\n",
|
721 |
+
" prompt=chat_prompt,\n",
|
722 |
+
")\n",
|
723 |
+
"quiz_data = chain.run(transcript)\n",
|
724 |
+
"print(type(quiz_data))\n",
|
725 |
+
"print(quiz_data)"
|
726 |
+
]
|
727 |
+
},
|
728 |
+
{
|
729 |
+
"cell_type": "markdown",
|
730 |
+
"id": "033e47fa",
|
731 |
+
"metadata": {},
|
732 |
+
"source": [
|
733 |
+
"## 4. Transform output"
|
734 |
+
]
|
735 |
+
},
|
736 |
+
{
|
737 |
+
"cell_type": "code",
|
738 |
+
"execution_count": 5,
|
739 |
+
"id": "b062f162",
|
740 |
+
"metadata": {},
|
741 |
+
"outputs": [
|
742 |
+
{
|
743 |
+
"name": "stdout",
|
744 |
+
"output_type": "stream",
|
745 |
+
"text": [
|
746 |
+
"<class 'list'>\n",
|
747 |
+
"[['What is the purpose of the video?', 'To demonstrate how to use Python inside Excel', 'To explain the limitations of using Python in Excel', 'To showcase different data visualization libraries'], ['What is the advantage of using pandas in Python?', 'It makes certain calculations with dates and times easier', 'It allows for the creation of fancy charts', 'It speeds up the calculation process in Excel'], ['How can you display a statistical summary of a dataframe in Excel?', \"By selecting 'Excel value' from the drop-down list\", 'By clicking on the preview icon', 'By right-clicking on the dataframe object'], [\"What is the purpose of the 'Calc_Method' cell?\", 'To specify the aggregation method for the top 5 selling products', 'To determine the color scheme for the charts', 'To calculate the month-over-month growth rate'], ['What are some limitations of using Python in Excel?', 'Animated charts and external file connections are not supported', 'It only works on Windows and with Excel Desktop 365 Beta Channel', 'Only libraries supported by Anaconda can be used']]\n"
|
748 |
+
]
|
749 |
+
}
|
750 |
+
],
|
751 |
+
"source": [
|
752 |
+
"import ast\n",
|
753 |
+
"\n",
|
754 |
+
"quiz_data_clean = ast.literal_eval(quiz_data)\n",
|
755 |
+
"print(type(quiz_data_clean))\n",
|
756 |
+
"print(quiz_data_clean)"
|
757 |
+
]
|
758 |
+
}
|
759 |
+
],
|
760 |
+
"metadata": {
|
761 |
+
"kernelspec": {
|
762 |
+
"display_name": "Python 3 (ipykernel)",
|
763 |
+
"language": "python",
|
764 |
+
"name": "python3"
|
765 |
+
},
|
766 |
+
"language_info": {
|
767 |
+
"codemirror_mode": {
|
768 |
+
"name": "ipython",
|
769 |
+
"version": 3
|
770 |
+
},
|
771 |
+
"file_extension": ".py",
|
772 |
+
"mimetype": "text/x-python",
|
773 |
+
"name": "python",
|
774 |
+
"nbconvert_exporter": "python",
|
775 |
+
"pygments_lexer": "ipython3",
|
776 |
+
"version": "3.11.1"
|
777 |
+
}
|
778 |
+
},
|
779 |
+
"nbformat": 4,
|
780 |
+
"nbformat_minor": 5
|
781 |
+
}
|