matildetesler commited on
Commit
a379c48
Β·
verified Β·
1 Parent(s): c17b1b1

Upload 2 files

Browse files
1_Data_Creation- TESLER (1).ipynb ADDED
@@ -0,0 +1,1434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {
6
+ "id": "4ba6aba8"
7
+ },
8
+ "source": [
9
+ "# πŸ€– **Data Collection, Creation, Storage, and Processing**\n"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "markdown",
14
+ "metadata": {
15
+ "id": "jpASMyIQMaAq"
16
+ },
17
+ "source": [
18
+ "## **1.** πŸ“¦ Install required packages"
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "execution_count": null,
24
+ "metadata": {
25
+ "colab": {
26
+ "base_uri": "https://localhost:8080/"
27
+ },
28
+ "id": "f48c8f8c",
29
+ "outputId": "a3bac449-590f-44e4-fa36-a6b14ff249c4"
30
+ },
31
+ "outputs": [
32
+ {
33
+ "output_type": "stream",
34
+ "name": "stdout",
35
+ "text": [
36
+ "Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.12/dist-packages (4.13.5)\n",
37
+ "Requirement already satisfied: pandas in /usr/local/lib/python3.12/dist-packages (2.2.2)\n",
38
+ "Requirement already satisfied: matplotlib in /usr/local/lib/python3.12/dist-packages (3.10.0)\n",
39
+ "Requirement already satisfied: seaborn in /usr/local/lib/python3.12/dist-packages (0.13.2)\n",
40
+ "Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (2.0.2)\n",
41
+ "Requirement already satisfied: textblob in /usr/local/lib/python3.12/dist-packages (0.19.0)\n",
42
+ "Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.12/dist-packages (from beautifulsoup4) (2.8.3)\n",
43
+ "Requirement already satisfied: typing-extensions>=4.0.0 in /usr/local/lib/python3.12/dist-packages (from beautifulsoup4) (4.15.0)\n",
44
+ "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.9.0.post0)\n",
45
+ "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
46
+ "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.3)\n",
47
+ "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.3.3)\n",
48
+ "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (0.12.1)\n",
49
+ "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (4.61.1)\n",
50
+ "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.4.9)\n",
51
+ "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (26.0)\n",
52
+ "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (11.3.0)\n",
53
+ "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (3.3.2)\n",
54
+ "Requirement already satisfied: nltk>=3.9 in /usr/local/lib/python3.12/dist-packages (from textblob) (3.9.1)\n",
55
+ "Requirement already satisfied: click in /usr/local/lib/python3.12/dist-packages (from nltk>=3.9->textblob) (8.3.1)\n",
56
+ "Requirement already satisfied: joblib in /usr/local/lib/python3.12/dist-packages (from nltk>=3.9->textblob) (1.5.3)\n",
57
+ "Requirement already satisfied: regex>=2021.8.3 in /usr/local/lib/python3.12/dist-packages (from nltk>=3.9->textblob) (2025.11.3)\n",
58
+ "Requirement already satisfied: tqdm in /usr/local/lib/python3.12/dist-packages (from nltk>=3.9->textblob) (4.67.3)\n",
59
+ "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n"
60
+ ]
61
+ }
62
+ ],
63
+ "source": [
64
+ "!pip install beautifulsoup4 pandas matplotlib seaborn numpy textblob"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "markdown",
69
+ "metadata": {
70
+ "id": "lquNYCbfL9IM"
71
+ },
72
+ "source": [
73
+ "## **2.** ⛏ Web-scrape all book titles, prices, and ratings from books.toscrape.com"
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "markdown",
78
+ "metadata": {
79
+ "id": "0IWuNpxxYDJF"
80
+ },
81
+ "source": [
82
+ "### *a. Initial setup*\n",
83
+ "Define the base url of the website you will scrape as well as how and what you will scrape"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "code",
88
+ "execution_count": null,
89
+ "metadata": {
90
+ "id": "91d52125"
91
+ },
92
+ "outputs": [],
93
+ "source": [
94
+ "import requests\n",
95
+ "from bs4 import BeautifulSoup\n",
96
+ "import pandas as pd\n",
97
+ "import time\n",
98
+ "\n",
99
+ "base_url = \"https://books.toscrape.com/catalogue/page-{}.html\"\n",
100
+ "headers = {\"User-Agent\": \"Mozilla/5.0\"}\n",
101
+ "\n",
102
+ "titles, prices, ratings = [], [], []"
103
+ ]
104
+ },
105
+ {
106
+ "cell_type": "markdown",
107
+ "metadata": {
108
+ "id": "oCdTsin2Yfp3"
109
+ },
110
+ "source": [
111
+ "### *b. Fill titles, prices, and ratings from the web pages*"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "code",
116
+ "execution_count": null,
117
+ "metadata": {
118
+ "id": "xqO5Y3dnYhxt",
119
+ "colab": {
120
+ "base_uri": "https://localhost:8080/",
121
+ "height": 176
122
+ },
123
+ "outputId": "e919f895-36dc-4a58-9e42-1beeda845598"
124
+ },
125
+ "outputs": [
126
+ {
127
+ "output_type": "error",
128
+ "ename": "KeyboardInterrupt",
129
+ "evalue": "",
130
+ "traceback": [
131
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
132
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
133
+ "\u001b[0;32m/tmp/ipykernel_576/2455262737.py\u001b[0m in \u001b[0;36m<cell line: 0>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0mratings\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbook\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"class\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0.5\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# polite scraping delay\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
134
+ "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
135
+ ]
136
+ }
137
+ ],
138
+ "source": [
139
+ "# Loop through all 50 pages\n",
140
+ "for page in range(1, 51):\n",
141
+ " url = base_url.format(page)\n",
142
+ " response = requests.get(url, headers=headers)\n",
143
+ " soup = BeautifulSoup(response.content, \"html.parser\")\n",
144
+ " books = soup.find_all(\"article\", class_=\"product_pod\")\n",
145
+ "\n",
146
+ " for book in books:\n",
147
+ " titles.append(book.h3.a[\"title\"])\n",
148
+ " prices.append(float(book.find(\"p\", class_=\"price_color\").text[1:]))\n",
149
+ " ratings.append(book.p.get(\"class\")[1])\n",
150
+ "\n",
151
+ " time.sleep(0.5) # polite scraping delay"
152
+ ]
153
+ },
154
+ {
155
+ "cell_type": "markdown",
156
+ "metadata": {
157
+ "id": "T0TOeRC4Yrnn"
158
+ },
159
+ "source": [
160
+ "### *c. βœ‹πŸ»πŸ›‘β›”οΈ Create a dataframe df_books that contains the now complete \"title\", \"price\", and \"rating\" objects*"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "code",
165
+ "execution_count": null,
166
+ "metadata": {
167
+ "id": "l5FkkNhUYTHh",
168
+ "colab": {
169
+ "base_uri": "https://localhost:8080/",
170
+ "height": 473
171
+ },
172
+ "outputId": "6e91e4cd-0fd4-47b7-f30f-27764a00c162"
173
+ },
174
+ "outputs": [
175
+ {
176
+ "output_type": "stream",
177
+ "name": "stdout",
178
+ "text": [
179
+ "<class 'pandas.core.frame.DataFrame'>\n",
180
+ "RangeIndex: 940 entries, 0 to 939\n",
181
+ "Data columns (total 3 columns):\n",
182
+ " # Column Non-Null Count Dtype \n",
183
+ "--- ------ -------------- ----- \n",
184
+ " 0 title 940 non-null object \n",
185
+ " 1 price 940 non-null float64\n",
186
+ " 2 rating 940 non-null int64 \n",
187
+ "dtypes: float64(1), int64(1), object(1)\n",
188
+ "memory usage: 22.2+ KB\n"
189
+ ]
190
+ },
191
+ {
192
+ "output_type": "execute_result",
193
+ "data": {
194
+ "text/plain": [
195
+ " price rating\n",
196
+ "count 940.000000 940.000000\n",
197
+ "mean 34.898543 2.917021\n",
198
+ "std 14.571643 1.440894\n",
199
+ "min 10.000000 1.000000\n",
200
+ "25% 21.857500 2.000000\n",
201
+ "50% 35.835000 3.000000\n",
202
+ "75% 47.682500 4.000000\n",
203
+ "max 59.990000 5.000000"
204
+ ],
205
+ "text/html": [
206
+ "\n",
207
+ " <div id=\"df-82c07860-8fa0-4a6a-b160-a143fafb67e2\" class=\"colab-df-container\">\n",
208
+ " <div>\n",
209
+ "<style scoped>\n",
210
+ " .dataframe tbody tr th:only-of-type {\n",
211
+ " vertical-align: middle;\n",
212
+ " }\n",
213
+ "\n",
214
+ " .dataframe tbody tr th {\n",
215
+ " vertical-align: top;\n",
216
+ " }\n",
217
+ "\n",
218
+ " .dataframe thead th {\n",
219
+ " text-align: right;\n",
220
+ " }\n",
221
+ "</style>\n",
222
+ "<table border=\"1\" class=\"dataframe\">\n",
223
+ " <thead>\n",
224
+ " <tr style=\"text-align: right;\">\n",
225
+ " <th></th>\n",
226
+ " <th>price</th>\n",
227
+ " <th>rating</th>\n",
228
+ " </tr>\n",
229
+ " </thead>\n",
230
+ " <tbody>\n",
231
+ " <tr>\n",
232
+ " <th>count</th>\n",
233
+ " <td>940.000000</td>\n",
234
+ " <td>940.000000</td>\n",
235
+ " </tr>\n",
236
+ " <tr>\n",
237
+ " <th>mean</th>\n",
238
+ " <td>34.898543</td>\n",
239
+ " <td>2.917021</td>\n",
240
+ " </tr>\n",
241
+ " <tr>\n",
242
+ " <th>std</th>\n",
243
+ " <td>14.571643</td>\n",
244
+ " <td>1.440894</td>\n",
245
+ " </tr>\n",
246
+ " <tr>\n",
247
+ " <th>min</th>\n",
248
+ " <td>10.000000</td>\n",
249
+ " <td>1.000000</td>\n",
250
+ " </tr>\n",
251
+ " <tr>\n",
252
+ " <th>25%</th>\n",
253
+ " <td>21.857500</td>\n",
254
+ " <td>2.000000</td>\n",
255
+ " </tr>\n",
256
+ " <tr>\n",
257
+ " <th>50%</th>\n",
258
+ " <td>35.835000</td>\n",
259
+ " <td>3.000000</td>\n",
260
+ " </tr>\n",
261
+ " <tr>\n",
262
+ " <th>75%</th>\n",
263
+ " <td>47.682500</td>\n",
264
+ " <td>4.000000</td>\n",
265
+ " </tr>\n",
266
+ " <tr>\n",
267
+ " <th>max</th>\n",
268
+ " <td>59.990000</td>\n",
269
+ " <td>5.000000</td>\n",
270
+ " </tr>\n",
271
+ " </tbody>\n",
272
+ "</table>\n",
273
+ "</div>\n",
274
+ " <div class=\"colab-df-buttons\">\n",
275
+ "\n",
276
+ " <div class=\"colab-df-container\">\n",
277
+ " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-82c07860-8fa0-4a6a-b160-a143fafb67e2')\"\n",
278
+ " title=\"Convert this dataframe to an interactive table.\"\n",
279
+ " style=\"display:none;\">\n",
280
+ "\n",
281
+ " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
282
+ " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
283
+ " </svg>\n",
284
+ " </button>\n",
285
+ "\n",
286
+ " <style>\n",
287
+ " .colab-df-container {\n",
288
+ " display:flex;\n",
289
+ " gap: 12px;\n",
290
+ " }\n",
291
+ "\n",
292
+ " .colab-df-convert {\n",
293
+ " background-color: #E8F0FE;\n",
294
+ " border: none;\n",
295
+ " border-radius: 50%;\n",
296
+ " cursor: pointer;\n",
297
+ " display: none;\n",
298
+ " fill: #1967D2;\n",
299
+ " height: 32px;\n",
300
+ " padding: 0 0 0 0;\n",
301
+ " width: 32px;\n",
302
+ " }\n",
303
+ "\n",
304
+ " .colab-df-convert:hover {\n",
305
+ " background-color: #E2EBFA;\n",
306
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
307
+ " fill: #174EA6;\n",
308
+ " }\n",
309
+ "\n",
310
+ " .colab-df-buttons div {\n",
311
+ " margin-bottom: 4px;\n",
312
+ " }\n",
313
+ "\n",
314
+ " [theme=dark] .colab-df-convert {\n",
315
+ " background-color: #3B4455;\n",
316
+ " fill: #D2E3FC;\n",
317
+ " }\n",
318
+ "\n",
319
+ " [theme=dark] .colab-df-convert:hover {\n",
320
+ " background-color: #434B5C;\n",
321
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
322
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
323
+ " fill: #FFFFFF;\n",
324
+ " }\n",
325
+ " </style>\n",
326
+ "\n",
327
+ " <script>\n",
328
+ " const buttonEl =\n",
329
+ " document.querySelector('#df-82c07860-8fa0-4a6a-b160-a143fafb67e2 button.colab-df-convert');\n",
330
+ " buttonEl.style.display =\n",
331
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
332
+ "\n",
333
+ " async function convertToInteractive(key) {\n",
334
+ " const element = document.querySelector('#df-82c07860-8fa0-4a6a-b160-a143fafb67e2');\n",
335
+ " const dataTable =\n",
336
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
337
+ " [key], {});\n",
338
+ " if (!dataTable) return;\n",
339
+ "\n",
340
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n",
341
+ " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
342
+ " + ' to learn more about interactive tables.';\n",
343
+ " element.innerHTML = '';\n",
344
+ " dataTable['output_type'] = 'display_data';\n",
345
+ " await google.colab.output.renderOutput(dataTable, element);\n",
346
+ " const docLink = document.createElement('div');\n",
347
+ " docLink.innerHTML = docLinkHtml;\n",
348
+ " element.appendChild(docLink);\n",
349
+ " }\n",
350
+ " </script>\n",
351
+ " </div>\n",
352
+ "\n",
353
+ "\n",
354
+ " </div>\n",
355
+ " </div>\n"
356
+ ],
357
+ "application/vnd.google.colaboratory.intrinsic+json": {
358
+ "type": "dataframe",
359
+ "summary": "{\n \"name\": \"df_books\",\n \"rows\": 8,\n \"fields\": [\n {\n \"column\": \"price\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 321.4163817567838,\n \"min\": 10.0,\n \"max\": 940.0,\n \"num_unique_values\": 8,\n \"samples\": [\n 34.8985425531915,\n 35.835,\n 940.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 331.36506283836815,\n \"min\": 1.0,\n \"max\": 940.0,\n \"num_unique_values\": 8,\n \"samples\": [\n 2.9170212765957446,\n 3.0,\n 940.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
360
+ }
361
+ },
362
+ "metadata": {},
363
+ "execution_count": 13
364
+ }
365
+ ],
366
+ "source": [
367
+ "df_books = pd.DataFrame({\n",
368
+ " \"title\": titles,\n",
369
+ " \"price\": prices,\n",
370
+ " \"rating\": ratings\n",
371
+ "})\n",
372
+ "\n",
373
+ "df_books.head()\n",
374
+ "\n",
375
+ "rating_map = {\n",
376
+ " \"One\": 1,\n",
377
+ " \"Two\": 2,\n",
378
+ " \"Three\": 3,\n",
379
+ " \"Four\": 4,\n",
380
+ " \"Five\": 5\n",
381
+ "}\n",
382
+ "\n",
383
+ "df_books[\"rating\"] = df_books[\"rating\"].map(rating_map)\n",
384
+ "\n",
385
+ "df_books.info()\n",
386
+ "df_books.describe()"
387
+ ]
388
+ },
389
+ {
390
+ "cell_type": "markdown",
391
+ "metadata": {
392
+ "id": "duI5dv3CZYvF"
393
+ },
394
+ "source": [
395
+ "### *d. Save web-scraped dataframe either as a CSV or Excel file*"
396
+ ]
397
+ },
398
+ {
399
+ "cell_type": "code",
400
+ "execution_count": null,
401
+ "metadata": {
402
+ "id": "lC1U_YHtZifh"
403
+ },
404
+ "outputs": [],
405
+ "source": [
406
+ "# πŸ’Ύ Save to CSV\n",
407
+ "df_books.to_csv(\"books_data.csv\", index=False)\n",
408
+ "\n",
409
+ "# πŸ’Ύ Or save to Excel\n",
410
+ "# df_books.to_excel(\"books_data.xlsx\", index=False)"
411
+ ]
412
+ },
413
+ {
414
+ "cell_type": "markdown",
415
+ "metadata": {
416
+ "id": "qMjRKMBQZlJi"
417
+ },
418
+ "source": [
419
+ "### *e. βœ‹πŸ»πŸ›‘β›”οΈ View first fiew lines*"
420
+ ]
421
+ },
422
+ {
423
+ "cell_type": "code",
424
+ "execution_count": null,
425
+ "metadata": {
426
+ "colab": {
427
+ "base_uri": "https://localhost:8080/"
428
+ },
429
+ "id": "O_wIvTxYZqCK",
430
+ "outputId": "51a8f74c-243f-46a0-856c-f7f4d4e9cb06"
431
+ },
432
+ "outputs": [
433
+ {
434
+ "output_type": "execute_result",
435
+ "data": {
436
+ "text/plain": [
437
+ " title price rating\n",
438
+ "0 A Light in the Attic 51.77 3\n",
439
+ "1 Tipping the Velvet 53.74 1\n",
440
+ "2 Soumission 50.10 1\n",
441
+ "3 Sharp Objects 47.82 4\n",
442
+ "4 Sapiens: A Brief History of Humankind 54.23 5"
443
+ ],
444
+ "text/html": [
445
+ "\n",
446
+ " <div id=\"df-481d10c5-b834-4ffe-8e35-28de107f68aa\" class=\"colab-df-container\">\n",
447
+ " <div>\n",
448
+ "<style scoped>\n",
449
+ " .dataframe tbody tr th:only-of-type {\n",
450
+ " vertical-align: middle;\n",
451
+ " }\n",
452
+ "\n",
453
+ " .dataframe tbody tr th {\n",
454
+ " vertical-align: top;\n",
455
+ " }\n",
456
+ "\n",
457
+ " .dataframe thead th {\n",
458
+ " text-align: right;\n",
459
+ " }\n",
460
+ "</style>\n",
461
+ "<table border=\"1\" class=\"dataframe\">\n",
462
+ " <thead>\n",
463
+ " <tr style=\"text-align: right;\">\n",
464
+ " <th></th>\n",
465
+ " <th>title</th>\n",
466
+ " <th>price</th>\n",
467
+ " <th>rating</th>\n",
468
+ " </tr>\n",
469
+ " </thead>\n",
470
+ " <tbody>\n",
471
+ " <tr>\n",
472
+ " <th>0</th>\n",
473
+ " <td>A Light in the Attic</td>\n",
474
+ " <td>51.77</td>\n",
475
+ " <td>3</td>\n",
476
+ " </tr>\n",
477
+ " <tr>\n",
478
+ " <th>1</th>\n",
479
+ " <td>Tipping the Velvet</td>\n",
480
+ " <td>53.74</td>\n",
481
+ " <td>1</td>\n",
482
+ " </tr>\n",
483
+ " <tr>\n",
484
+ " <th>2</th>\n",
485
+ " <td>Soumission</td>\n",
486
+ " <td>50.10</td>\n",
487
+ " <td>1</td>\n",
488
+ " </tr>\n",
489
+ " <tr>\n",
490
+ " <th>3</th>\n",
491
+ " <td>Sharp Objects</td>\n",
492
+ " <td>47.82</td>\n",
493
+ " <td>4</td>\n",
494
+ " </tr>\n",
495
+ " <tr>\n",
496
+ " <th>4</th>\n",
497
+ " <td>Sapiens: A Brief History of Humankind</td>\n",
498
+ " <td>54.23</td>\n",
499
+ " <td>5</td>\n",
500
+ " </tr>\n",
501
+ " </tbody>\n",
502
+ "</table>\n",
503
+ "</div>\n",
504
+ " <div class=\"colab-df-buttons\">\n",
505
+ "\n",
506
+ " <div class=\"colab-df-container\">\n",
507
+ " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-481d10c5-b834-4ffe-8e35-28de107f68aa')\"\n",
508
+ " title=\"Convert this dataframe to an interactive table.\"\n",
509
+ " style=\"display:none;\">\n",
510
+ "\n",
511
+ " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
512
+ " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
513
+ " </svg>\n",
514
+ " </button>\n",
515
+ "\n",
516
+ " <style>\n",
517
+ " .colab-df-container {\n",
518
+ " display:flex;\n",
519
+ " gap: 12px;\n",
520
+ " }\n",
521
+ "\n",
522
+ " .colab-df-convert {\n",
523
+ " background-color: #E8F0FE;\n",
524
+ " border: none;\n",
525
+ " border-radius: 50%;\n",
526
+ " cursor: pointer;\n",
527
+ " display: none;\n",
528
+ " fill: #1967D2;\n",
529
+ " height: 32px;\n",
530
+ " padding: 0 0 0 0;\n",
531
+ " width: 32px;\n",
532
+ " }\n",
533
+ "\n",
534
+ " .colab-df-convert:hover {\n",
535
+ " background-color: #E2EBFA;\n",
536
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
537
+ " fill: #174EA6;\n",
538
+ " }\n",
539
+ "\n",
540
+ " .colab-df-buttons div {\n",
541
+ " margin-bottom: 4px;\n",
542
+ " }\n",
543
+ "\n",
544
+ " [theme=dark] .colab-df-convert {\n",
545
+ " background-color: #3B4455;\n",
546
+ " fill: #D2E3FC;\n",
547
+ " }\n",
548
+ "\n",
549
+ " [theme=dark] .colab-df-convert:hover {\n",
550
+ " background-color: #434B5C;\n",
551
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
552
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
553
+ " fill: #FFFFFF;\n",
554
+ " }\n",
555
+ " </style>\n",
556
+ "\n",
557
+ " <script>\n",
558
+ " const buttonEl =\n",
559
+ " document.querySelector('#df-481d10c5-b834-4ffe-8e35-28de107f68aa button.colab-df-convert');\n",
560
+ " buttonEl.style.display =\n",
561
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
562
+ "\n",
563
+ " async function convertToInteractive(key) {\n",
564
+ " const element = document.querySelector('#df-481d10c5-b834-4ffe-8e35-28de107f68aa');\n",
565
+ " const dataTable =\n",
566
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
567
+ " [key], {});\n",
568
+ " if (!dataTable) return;\n",
569
+ "\n",
570
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n",
571
+ " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
572
+ " + ' to learn more about interactive tables.';\n",
573
+ " element.innerHTML = '';\n",
574
+ " dataTable['output_type'] = 'display_data';\n",
575
+ " await google.colab.output.renderOutput(dataTable, element);\n",
576
+ " const docLink = document.createElement('div');\n",
577
+ " docLink.innerHTML = docLinkHtml;\n",
578
+ " element.appendChild(docLink);\n",
579
+ " }\n",
580
+ " </script>\n",
581
+ " </div>\n",
582
+ "\n",
583
+ "\n",
584
+ " </div>\n",
585
+ " </div>\n"
586
+ ],
587
+ "application/vnd.google.colaboratory.intrinsic+json": {
588
+ "type": "dataframe",
589
+ "variable_name": "df_books",
590
+ "summary": "{\n \"name\": \"df_books\",\n \"rows\": 940,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 939,\n \"samples\": [\n \"Hush, Hush (Hush, Hush #1)\",\n \"The Mindfulness and Acceptance Workbook for Anxiety: A Guide to Breaking Free from Anxiety, Phobias, and Worry Using Acceptance and Commitment Therapy\",\n \"The Wedding Dress\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"price\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 14.571643268466614,\n \"min\": 10.0,\n \"max\": 59.99,\n \"num_unique_values\": 854,\n \"samples\": [\n 56.06,\n 36.91,\n 37.8\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1,\n \"max\": 5,\n \"num_unique_values\": 5,\n \"samples\": [\n 1,\n 2,\n 4\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
591
+ }
592
+ },
593
+ "metadata": {},
594
+ "execution_count": 15
595
+ }
596
+ ],
597
+ "source": [
598
+ "df_books.head()"
599
+ ]
600
+ },
601
+ {
602
+ "cell_type": "markdown",
603
+ "metadata": {
604
+ "id": "p-1Pr2szaqLk"
605
+ },
606
+ "source": [
607
+ "## **3.** 🧩 Create a meaningful connection between real & synthetic datasets"
608
+ ]
609
+ },
610
+ {
611
+ "cell_type": "markdown",
612
+ "metadata": {
613
+ "id": "SIaJUGIpaH4V"
614
+ },
615
+ "source": [
616
+ "### *a. Initial setup*"
617
+ ]
618
+ },
619
+ {
620
+ "cell_type": "code",
621
+ "execution_count": null,
622
+ "metadata": {
623
+ "id": "-gPXGcRPuV_9"
624
+ },
625
+ "outputs": [],
626
+ "source": [
627
+ "import numpy as np\n",
628
+ "import random\n",
629
+ "from datetime import datetime\n",
630
+ "import warnings\n",
631
+ "\n",
632
+ "warnings.filterwarnings(\"ignore\")\n",
633
+ "random.seed(2025)\n",
634
+ "np.random.seed(2025)"
635
+ ]
636
+ },
637
+ {
638
+ "cell_type": "markdown",
639
+ "metadata": {
640
+ "id": "pY4yCoIuaQqp"
641
+ },
642
+ "source": [
643
+ "### *b. Generate popularity scores based on rating (with some randomness) with a generate_popularity_score function*"
644
+ ]
645
+ },
646
+ {
647
+ "cell_type": "code",
648
+ "execution_count": null,
649
+ "metadata": {
650
+ "id": "mnd5hdAbaNjz"
651
+ },
652
+ "outputs": [],
653
+ "source": [
654
+ "def generate_popularity_score(rating):\n",
655
+ " base = {\"One\": 2, \"Two\": 3, \"Three\": 3, \"Four\": 4, \"Five\": 4}.get(rating, 3)\n",
656
+ " trend_factor = random.choices([-1, 0, 1], weights=[1, 3, 2])[0]\n",
657
+ " return int(np.clip(base + trend_factor, 1, 5))"
658
+ ]
659
+ },
660
+ {
661
+ "cell_type": "markdown",
662
+ "metadata": {
663
+ "id": "n4-TaNTFgPak"
664
+ },
665
+ "source": [
666
+ "### *c. βœ‹πŸ»πŸ›‘β›”οΈ Run the function to create a \"popularity_score\" column from \"rating\"*"
667
+ ]
668
+ },
669
+ {
670
+ "cell_type": "code",
671
+ "execution_count": null,
672
+ "metadata": {
673
+ "id": "V-G3OCUCgR07",
674
+ "colab": {
675
+ "base_uri": "https://localhost:8080/"
676
+ },
677
+ "outputId": "12a853c6-7253-4892-ca16-a7e9587fe127"
678
+ },
679
+ "outputs": [
680
+ {
681
+ "output_type": "stream",
682
+ "name": "stdout",
683
+ "text": [
684
+ "Columns: Index(['title', 'price', 'rating', 'popularity_score', 'sentiment_label'], dtype='object')\n",
685
+ "\n",
686
+ "First 5 rows:\n",
687
+ " title price rating popularity_score \\\n",
688
+ "0 A Light in the Attic 51.77 3 3 \n",
689
+ "1 Tipping the Velvet 53.74 1 1 \n",
690
+ "2 Soumission 50.10 1 1 \n",
691
+ "3 Sharp Objects 47.82 4 4 \n",
692
+ "4 Sapiens: A Brief History of Humankind 54.23 5 4 \n",
693
+ "\n",
694
+ " sentiment_label \n",
695
+ "0 neutral \n",
696
+ "1 negative \n",
697
+ "2 negative \n",
698
+ "3 positive \n",
699
+ "4 positive \n",
700
+ "\n",
701
+ "Distribution of popularity_score:\n",
702
+ "popularity_score\n",
703
+ "1 184\n",
704
+ "2 196\n",
705
+ "3 174\n",
706
+ "4 179\n",
707
+ "5 207\n",
708
+ "Name: count, dtype: int64\n"
709
+ ]
710
+ }
711
+ ],
712
+ "source": [
713
+ "# --- Imports (if not already imported) ---\n",
714
+ "import numpy as np\n",
715
+ "import random\n",
716
+ "\n",
717
+ "# --- Reproducibility ---\n",
718
+ "random.seed(2025)\n",
719
+ "np.random.seed(2025)\n",
720
+ "\n",
721
+ "# --- Ensure column names have no hidden spaces ---\n",
722
+ "df_books.columns = df_books.columns.str.strip()\n",
723
+ "\n",
724
+ "# --- Confirm rating column exists ---\n",
725
+ "if \"rating\" not in df_books.columns:\n",
726
+ " raise ValueError(\"Column 'rating' not found in df_books\")\n",
727
+ "\n",
728
+ "# --- Define popularity score generator (for numeric ratings 1–5) ---\n",
729
+ "def generate_popularity_score(rating):\n",
730
+ " trend_factor = random.choices([-1, 0, 1], weights=[1, 3, 2])[0]\n",
731
+ " return int(np.clip(rating + trend_factor, 1, 5))\n",
732
+ "\n",
733
+ "# --- Create new column ---\n",
734
+ "df_books[\"popularity_score\"] = df_books[\"rating\"].apply(generate_popularity_score)\n",
735
+ "\n",
736
+ "# --- Verify output ---\n",
737
+ "print(\"Columns:\", df_books.columns)\n",
738
+ "print(\"\\nFirst 5 rows:\")\n",
739
+ "print(df_books.head())\n",
740
+ "\n",
741
+ "print(\"\\nDistribution of popularity_score:\")\n",
742
+ "print(df_books[\"popularity_score\"].value_counts().sort_index())"
743
+ ]
744
+ },
745
+ {
746
+ "cell_type": "markdown",
747
+ "metadata": {
748
+ "id": "HnngRNTgacYt"
749
+ },
750
+ "source": [
751
+ "### *d. Decide on the sentiment_label based on the popularity score with a get_sentiment function*"
752
+ ]
753
+ },
754
+ {
755
+ "cell_type": "code",
756
+ "execution_count": null,
757
+ "metadata": {
758
+ "id": "kUtWmr8maZLZ"
759
+ },
760
+ "outputs": [],
761
+ "source": [
762
+ "def get_sentiment(popularity_score):\n",
763
+ " if popularity_score <= 2:\n",
764
+ " return \"negative\"\n",
765
+ " elif popularity_score == 3:\n",
766
+ " return \"neutral\"\n",
767
+ " else:\n",
768
+ " return \"positive\""
769
+ ]
770
+ },
771
+ {
772
+ "cell_type": "markdown",
773
+ "metadata": {
774
+ "id": "HF9F9HIzgT7Z"
775
+ },
776
+ "source": [
777
+ "### *e. βœ‹πŸ»πŸ›‘β›”οΈ Run the function to create a \"sentiment_label\" column from \"popularity_score\"*"
778
+ ]
779
+ },
780
+ {
781
+ "cell_type": "code",
782
+ "execution_count": null,
783
+ "metadata": {
784
+ "id": "tafQj8_7gYCG",
785
+ "colab": {
786
+ "base_uri": "https://localhost:8080/"
787
+ },
788
+ "outputId": "80df923c-021f-4957-a774-98c1348d8f19"
789
+ },
790
+ "outputs": [
791
+ {
792
+ "output_type": "stream",
793
+ "name": "stdout",
794
+ "text": [
795
+ "Columns: Index(['title', 'price', 'rating', 'popularity_score', 'sentiment_label'], dtype='object')\n",
796
+ "\n",
797
+ "First 5 rows:\n",
798
+ " title price rating popularity_score \\\n",
799
+ "0 A Light in the Attic 51.77 3 3 \n",
800
+ "1 Tipping the Velvet 53.74 1 1 \n",
801
+ "2 Soumission 50.10 1 1 \n",
802
+ "3 Sharp Objects 47.82 4 4 \n",
803
+ "4 Sapiens: A Brief History of Humankind 54.23 5 4 \n",
804
+ "\n",
805
+ " sentiment_label \n",
806
+ "0 neutral \n",
807
+ "1 negative \n",
808
+ "2 negative \n",
809
+ "3 positive \n",
810
+ "4 positive \n",
811
+ "\n",
812
+ "Sentiment distribution:\n",
813
+ "sentiment_label\n",
814
+ "positive 386\n",
815
+ "negative 380\n",
816
+ "neutral 174\n",
817
+ "Name: count, dtype: int64\n"
818
+ ]
819
+ }
820
+ ],
821
+ "source": [
822
+ "# --- Ensure popularity_score exists ---\n",
823
+ "if \"popularity_score\" not in df_books.columns:\n",
824
+ " raise ValueError(\"Column 'popularity_score' not found in df_books\")\n",
825
+ "\n",
826
+ "# --- Create sentiment_label column ---\n",
827
+ "df_books[\"sentiment_label\"] = df_books[\"popularity_score\"].apply(get_sentiment)\n",
828
+ "\n",
829
+ "# --- Verify results ---\n",
830
+ "print(\"Columns:\", df_books.columns)\n",
831
+ "\n",
832
+ "print(\"\\nFirst 5 rows:\")\n",
833
+ "print(df_books.head())\n",
834
+ "\n",
835
+ "print(\"\\nSentiment distribution:\")\n",
836
+ "print(df_books[\"sentiment_label\"].value_counts())"
837
+ ]
838
+ },
839
+ {
840
+ "cell_type": "markdown",
841
+ "metadata": {
842
+ "id": "T8AdKkmASq9a"
843
+ },
844
+ "source": [
845
+ "## **4.** πŸ“ˆ Generate synthetic book sales data of 18 months"
846
+ ]
847
+ },
848
+ {
849
+ "cell_type": "markdown",
850
+ "metadata": {
851
+ "id": "OhXbdGD5fH0c"
852
+ },
853
+ "source": [
854
+ "### *a. Create a generate_sales_profit function that would generate sales patterns based on sentiment_label (with some randomness)*"
855
+ ]
856
+ },
857
+ {
858
+ "cell_type": "code",
859
+ "execution_count": null,
860
+ "metadata": {
861
+ "id": "qkVhYPXGbgEn"
862
+ },
863
+ "outputs": [],
864
+ "source": [
865
+ "def generate_sales_profile(sentiment):\n",
866
+ " months = pd.date_range(end=datetime.today(), periods=18, freq=\"M\")\n",
867
+ "\n",
868
+ " if sentiment == \"positive\":\n",
869
+ " base = random.randint(200, 300)\n",
870
+ " trend = np.linspace(base, base + random.randint(20, 60), len(months))\n",
871
+ " elif sentiment == \"negative\":\n",
872
+ " base = random.randint(20, 80)\n",
873
+ " trend = np.linspace(base, base - random.randint(10, 30), len(months))\n",
874
+ " else: # neutral\n",
875
+ " base = random.randint(80, 160)\n",
876
+ " trend = np.full(len(months), base + random.randint(-10, 10))\n",
877
+ "\n",
878
+ " seasonality = 10 * np.sin(np.linspace(0, 3 * np.pi, len(months)))\n",
879
+ " noise = np.random.normal(0, 5, len(months))\n",
880
+ " monthly_sales = np.clip(trend + seasonality + noise, a_min=0, a_max=None).astype(int)\n",
881
+ "\n",
882
+ " return list(zip(months.strftime(\"%Y-%m\"), monthly_sales))"
883
+ ]
884
+ },
885
+ {
886
+ "cell_type": "markdown",
887
+ "metadata": {
888
+ "id": "L2ak1HlcgoTe"
889
+ },
890
+ "source": [
891
+ "### *b. Run the function as part of building sales_data*"
892
+ ]
893
+ },
894
+ {
895
+ "cell_type": "code",
896
+ "execution_count": null,
897
+ "metadata": {
898
+ "id": "SlJ24AUafoDB"
899
+ },
900
+ "outputs": [],
901
+ "source": [
902
+ "sales_data = []\n",
903
+ "for _, row in df_books.iterrows():\n",
904
+ " records = generate_sales_profile(row[\"sentiment_label\"])\n",
905
+ " for month, units in records:\n",
906
+ " sales_data.append({\n",
907
+ " \"title\": row[\"title\"],\n",
908
+ " \"month\": month,\n",
909
+ " \"units_sold\": units,\n",
910
+ " \"sentiment_label\": row[\"sentiment_label\"]\n",
911
+ " })"
912
+ ]
913
+ },
914
+ {
915
+ "cell_type": "markdown",
916
+ "metadata": {
917
+ "id": "4IXZKcCSgxnq"
918
+ },
919
+ "source": [
920
+ "### *c. βœ‹πŸ»πŸ›‘β›”οΈ Create a df_sales DataFrame from sales_data*"
921
+ ]
922
+ },
923
+ {
924
+ "cell_type": "code",
925
+ "execution_count": null,
926
+ "metadata": {
927
+ "id": "wcN6gtiZg-ws",
928
+ "colab": {
929
+ "base_uri": "https://localhost:8080/"
930
+ },
931
+ "outputId": "18516e9e-edbb-451c-e9d5-f1d7d9fd17ed"
932
+ },
933
+ "outputs": [
934
+ {
935
+ "output_type": "stream",
936
+ "name": "stdout",
937
+ "text": [
938
+ "Sales Data Shape: (16920, 4)\n",
939
+ "\n",
940
+ "First 5 rows:\n",
941
+ " title month units_sold sentiment_label\n",
942
+ "0 A Light in the Attic 2024-09 105 neutral\n",
943
+ "1 A Light in the Attic 2024-10 103 neutral\n",
944
+ "2 A Light in the Attic 2024-11 110 neutral\n",
945
+ "3 A Light in the Attic 2024-12 117 neutral\n",
946
+ "4 A Light in the Attic 2025-01 109 neutral\n",
947
+ "\n",
948
+ "Months per book (should be 18):\n",
949
+ "title\n",
950
+ "\"Most Blessed of the Patriarchs\": Thomas Jefferson and the Empire of the Imagination 18\n",
951
+ "#GIRLBOSS 18\n",
952
+ "#HigherSelfie: Wake Up Your Life. Free Your Soul. Find Your Tribe. 18\n",
953
+ "'Salem's Lot 18\n",
954
+ "(Un)Qualified: How God Uses Broken People to Do Big Things 18\n",
955
+ "Name: month, dtype: int64\n"
956
+ ]
957
+ }
958
+ ],
959
+ "source": [
960
+ "# --- Required imports ---\n",
961
+ "import pandas as pd\n",
962
+ "import numpy as np\n",
963
+ "import random\n",
964
+ "from datetime import datetime\n",
965
+ "\n",
966
+ "# --- Ensure sentiment_label exists ---\n",
967
+ "if \"sentiment_label\" not in df_books.columns:\n",
968
+ " raise ValueError(\"Column 'sentiment_label' not found in df_books\")\n",
969
+ "\n",
970
+ "# --- Sales profile generator ---\n",
971
+ "def generate_sales_profile(sentiment):\n",
972
+ " months = pd.date_range(end=datetime.today(), periods=18, freq=\"M\")\n",
973
+ "\n",
974
+ " if sentiment == \"positive\":\n",
975
+ " base = random.randint(200, 300)\n",
976
+ " trend = np.linspace(base, base + random.randint(20, 60), len(months))\n",
977
+ " elif sentiment == \"negative\":\n",
978
+ " base = random.randint(20, 80)\n",
979
+ " trend = np.linspace(base, base - random.randint(10, 30), len(months))\n",
980
+ " else: # neutral\n",
981
+ " base = random.randint(80, 160)\n",
982
+ " trend = np.full(len(months), base + random.randint(-10, 10))\n",
983
+ "\n",
984
+ " seasonality = 10 * np.sin(np.linspace(0, 3 * np.pi, len(months)))\n",
985
+ " noise = np.random.normal(0, 5, len(months))\n",
986
+ "\n",
987
+ " monthly_sales = np.clip(trend + seasonality + noise, a_min=0, a_max=None).astype(int)\n",
988
+ "\n",
989
+ " return list(zip(months.strftime(\"%Y-%m\"), monthly_sales))\n",
990
+ "\n",
991
+ "\n",
992
+ "# --- Build sales_data list ---\n",
993
+ "sales_data = []\n",
994
+ "\n",
995
+ "for _, row in df_books.iterrows():\n",
996
+ " records = generate_sales_profile(row[\"sentiment_label\"])\n",
997
+ " for month, units in records:\n",
998
+ " sales_data.append({\n",
999
+ " \"title\": row[\"title\"],\n",
1000
+ " \"month\": month,\n",
1001
+ " \"units_sold\": units,\n",
1002
+ " \"sentiment_label\": row[\"sentiment_label\"]\n",
1003
+ " })\n",
1004
+ "\n",
1005
+ "# --- Convert to DataFrame ---\n",
1006
+ "df_sales = pd.DataFrame(sales_data)\n",
1007
+ "\n",
1008
+ "# --- Verify ---\n",
1009
+ "print(\"Sales Data Shape:\", df_sales.shape)\n",
1010
+ "print(\"\\nFirst 5 rows:\")\n",
1011
+ "print(df_sales.head())\n",
1012
+ "\n",
1013
+ "print(\"\\nMonths per book (should be 18):\")\n",
1014
+ "print(df_sales.groupby(\"title\")[\"month\"].count().head())"
1015
+ ]
1016
+ },
1017
+ {
1018
+ "cell_type": "markdown",
1019
+ "metadata": {
1020
+ "id": "EhIjz9WohAmZ"
1021
+ },
1022
+ "source": [
1023
+ "### *d. Save df_sales as synthetic_sales_data.csv & view first few lines*"
1024
+ ]
1025
+ },
1026
+ {
1027
+ "cell_type": "code",
1028
+ "execution_count": null,
1029
+ "metadata": {
1030
+ "colab": {
1031
+ "base_uri": "https://localhost:8080/"
1032
+ },
1033
+ "id": "MzbZvLcAhGaH",
1034
+ "outputId": "4d8bd347-9ab8-4b3d-ea27-e9041b5a6f36"
1035
+ },
1036
+ "outputs": [
1037
+ {
1038
+ "output_type": "stream",
1039
+ "name": "stdout",
1040
+ "text": [
1041
+ " title month units_sold sentiment_label\n",
1042
+ "0 A Light in the Attic 2024-09 105 neutral\n",
1043
+ "1 A Light in the Attic 2024-10 103 neutral\n",
1044
+ "2 A Light in the Attic 2024-11 110 neutral\n",
1045
+ "3 A Light in the Attic 2024-12 117 neutral\n",
1046
+ "4 A Light in the Attic 2025-01 109 neutral\n"
1047
+ ]
1048
+ }
1049
+ ],
1050
+ "source": [
1051
+ "df_sales.to_csv(\"synthetic_sales_data.csv\", index=False)\n",
1052
+ "\n",
1053
+ "print(df_sales.head())"
1054
+ ]
1055
+ },
1056
+ {
1057
+ "cell_type": "markdown",
1058
+ "metadata": {
1059
+ "id": "7g9gqBgQMtJn"
1060
+ },
1061
+ "source": [
1062
+ "## **5.** 🎯 Generate synthetic customer reviews"
1063
+ ]
1064
+ },
1065
+ {
1066
+ "cell_type": "markdown",
1067
+ "metadata": {
1068
+ "id": "Gi4y9M9KuDWx"
1069
+ },
1070
+ "source": [
1071
+ "### *a. βœ‹πŸ»πŸ›‘β›”οΈ Ask ChatGPT to create a list of 50 distinct generic book review texts for the sentiment labels \"positive\", \"neutral\", and \"negative\" called synthetic_reviews_by_sentiment*"
1072
+ ]
1073
+ },
1074
+ {
1075
+ "cell_type": "code",
1076
+ "source": [
1077
+ "import random\n",
1078
+ "import itertools\n",
1079
+ "\n",
1080
+ "random.seed(2025)\n",
1081
+ "\n",
1082
+ "def generate_reviews(sentiment, n=50):\n",
1083
+ " adjectives = {\n",
1084
+ " \"positive\": [\n",
1085
+ " \"excellent\", \"engaging\", \"compelling\", \"insightful\", \"captivating\",\n",
1086
+ " \"thought-provoking\", \"beautifully written\", \"masterfully crafted\",\n",
1087
+ " \"immersive\", \"inspiring\", \"memorable\", \"refreshing\", \"well-paced\"\n",
1088
+ " ],\n",
1089
+ " \"neutral\": [\n",
1090
+ " \"adequate\", \"acceptable\", \"moderate\", \"standard\", \"balanced\",\n",
1091
+ " \"straightforward\", \"predictable\", \"conventional\",\n",
1092
+ " \"reasonably structured\", \"competent\", \"simple\", \"average\", \"steady\"\n",
1093
+ " ],\n",
1094
+ " \"negative\": [\n",
1095
+ " \"disappointing\", \"confusing\", \"poorly written\", \"uninspired\",\n",
1096
+ " \"weak\", \"overly long\", \"underdeveloped\", \"inconsistent\",\n",
1097
+ " \"repetitive\", \"lackluster\", \"flat\", \"messy\", \"forgettable\"\n",
1098
+ " ]\n",
1099
+ " }\n",
1100
+ "\n",
1101
+ " templates = {\n",
1102
+ " \"positive\": [\n",
1103
+ " \"An {adj} read that exceeded expectations.\",\n",
1104
+ " \"A truly {adj} book that I would recommend.\",\n",
1105
+ " \"The story was {adj} and kept me interested throughout.\",\n",
1106
+ " \"Overall, a {adj} experience from beginning to end.\",\n",
1107
+ " \"A {adj} journey with strong moments and satisfying payoff.\"\n",
1108
+ " ],\n",
1109
+ " \"neutral\": [\n",
1110
+ " \"A fairly {adj} book overall.\",\n",
1111
+ " \"The reading experience was {adj} but not remarkable.\",\n",
1112
+ " \"An {adj} story that delivers what it promises.\",\n",
1113
+ " \"Overall, a {adj} and steady read.\",\n",
1114
+ " \"It felt {adj}: fine for passing time, but not standout.\"\n",
1115
+ " ],\n",
1116
+ " \"negative\": [\n",
1117
+ " \"A {adj} book that did not fully deliver.\",\n",
1118
+ " \"The story felt {adj} and difficult to enjoy.\",\n",
1119
+ " \"Overall, a rather {adj} experience.\",\n",
1120
+ " \"An unfortunately {adj} read.\",\n",
1121
+ " \"The pacing was {adj}, which made it hard to stay invested.\"\n",
1122
+ " ]\n",
1123
+ " }\n",
1124
+ "\n",
1125
+ " # Build ALL possible unique combinations, shuffle, then take n\n",
1126
+ " combos = [t.format(adj=a) for t, a in itertools.product(templates[sentiment], adjectives[sentiment])]\n",
1127
+ " random.shuffle(combos)\n",
1128
+ " return combos[:n]\n",
1129
+ "\n",
1130
+ "synthetic_reviews_by_sentiment = {\n",
1131
+ " \"positive\": generate_reviews(\"positive\", 50),\n",
1132
+ " \"neutral\": generate_reviews(\"neutral\", 50),\n",
1133
+ " \"negative\": generate_reviews(\"negative\", 50)\n",
1134
+ "}\n",
1135
+ "\n",
1136
+ "# Quick check\n",
1137
+ "for s, reviews in synthetic_reviews_by_sentiment.items():\n",
1138
+ " print(s, len(reviews), \"unique:\", len(set(reviews)))\n",
1139
+ " print(\"Sample:\", reviews[:3], \"\\n\")"
1140
+ ],
1141
+ "metadata": {
1142
+ "colab": {
1143
+ "base_uri": "https://localhost:8080/"
1144
+ },
1145
+ "id": "NGOUIvP3Yhei",
1146
+ "outputId": "79c0dad9-0255-4e28-fbcd-7f110fcf1e5e"
1147
+ },
1148
+ "execution_count": null,
1149
+ "outputs": [
1150
+ {
1151
+ "output_type": "stream",
1152
+ "name": "stdout",
1153
+ "text": [
1154
+ "positive 50 unique: 50\n",
1155
+ "Sample: ['Overall, a engaging experience from beginning to end.', 'A truly masterfully crafted book that I would recommend.', 'A truly thought-provoking book that I would recommend.'] \n",
1156
+ "\n",
1157
+ "neutral 50 unique: 50\n",
1158
+ "Sample: ['A fairly straightforward book overall.', 'A fairly average book overall.', 'The reading experience was moderate but not remarkable.'] \n",
1159
+ "\n",
1160
+ "negative 50 unique: 50\n",
1161
+ "Sample: ['An unfortunately messy read.', 'An unfortunately overly long read.', 'A underdeveloped book that did not fully deliver.'] \n",
1162
+ "\n"
1163
+ ]
1164
+ }
1165
+ ]
1166
+ },
1167
+ {
1168
+ "cell_type": "markdown",
1169
+ "metadata": {
1170
+ "id": "fQhfVaDmuULT"
1171
+ },
1172
+ "source": [
1173
+ "### *b. Generate 10 reviews per book using random sampling from the corresponding 50*"
1174
+ ]
1175
+ },
1176
+ {
1177
+ "cell_type": "code",
1178
+ "execution_count": null,
1179
+ "metadata": {
1180
+ "id": "l2SRc3PjuTGM"
1181
+ },
1182
+ "outputs": [],
1183
+ "source": [
1184
+ "review_rows = []\n",
1185
+ "for _, row in df_books.iterrows():\n",
1186
+ " title = row['title']\n",
1187
+ " sentiment_label = row['sentiment_label']\n",
1188
+ " review_pool = synthetic_reviews_by_sentiment[sentiment_label]\n",
1189
+ " sampled_reviews = random.sample(review_pool, 10)\n",
1190
+ " for review_text in sampled_reviews:\n",
1191
+ " review_rows.append({\n",
1192
+ " \"title\": title,\n",
1193
+ " \"sentiment_label\": sentiment_label,\n",
1194
+ " \"review_text\": review_text,\n",
1195
+ " \"rating\": row['rating'],\n",
1196
+ " \"popularity_score\": row['popularity_score']\n",
1197
+ " })"
1198
+ ]
1199
+ },
1200
+ {
1201
+ "cell_type": "markdown",
1202
+ "metadata": {
1203
+ "id": "bmJMXF-Bukdm"
1204
+ },
1205
+ "source": [
1206
+ "### *c. Create the final dataframe df_reviews & save it as synthetic_book_reviews.csv*"
1207
+ ]
1208
+ },
1209
+ {
1210
+ "cell_type": "code",
1211
+ "execution_count": null,
1212
+ "metadata": {
1213
+ "id": "ZUKUqZsuumsp"
1214
+ },
1215
+ "outputs": [],
1216
+ "source": [
1217
+ "df_reviews = pd.DataFrame(review_rows)\n",
1218
+ "df_reviews.to_csv(\"synthetic_book_reviews.csv\", index=False)"
1219
+ ]
1220
+ },
1221
+ {
1222
+ "cell_type": "markdown",
1223
+ "source": [
1224
+ "### *c. inputs for R*"
1225
+ ],
1226
+ "metadata": {
1227
+ "id": "_602pYUS3gY5"
1228
+ }
1229
+ },
1230
+ {
1231
+ "cell_type": "code",
1232
+ "execution_count": null,
1233
+ "metadata": {
1234
+ "colab": {
1235
+ "base_uri": "https://localhost:8080/"
1236
+ },
1237
+ "id": "3946e521",
1238
+ "outputId": "e60ce6f6-3be2-46e4-8c2c-7377064b2f6c"
1239
+ },
1240
+ "outputs": [
1241
+ {
1242
+ "output_type": "stream",
1243
+ "name": "stdout",
1244
+ "text": [
1245
+ "βœ… Wrote synthetic_title_level_features.csv\n",
1246
+ "βœ… Wrote synthetic_monthly_revenue_series.csv\n"
1247
+ ]
1248
+ }
1249
+ ],
1250
+ "source": [
1251
+ "import numpy as np\n",
1252
+ "\n",
1253
+ "def _safe_num(s):\n",
1254
+ " return pd.to_numeric(\n",
1255
+ " pd.Series(s).astype(str).str.replace(r\"[^0-9.]\", \"\", regex=True),\n",
1256
+ " errors=\"coerce\"\n",
1257
+ " )\n",
1258
+ "\n",
1259
+ "# --- Clean book metadata (price/rating) ---\n",
1260
+ "df_books_r = df_books.copy()\n",
1261
+ "if \"price\" in df_books_r.columns:\n",
1262
+ " df_books_r[\"price\"] = _safe_num(df_books_r[\"price\"])\n",
1263
+ "if \"rating\" in df_books_r.columns:\n",
1264
+ " df_books_r[\"rating\"] = _safe_num(df_books_r[\"rating\"])\n",
1265
+ "\n",
1266
+ "df_books_r[\"title\"] = df_books_r[\"title\"].astype(str).str.strip()\n",
1267
+ "\n",
1268
+ "# --- Clean sales ---\n",
1269
+ "df_sales_r = df_sales.copy()\n",
1270
+ "df_sales_r[\"title\"] = df_sales_r[\"title\"].astype(str).str.strip()\n",
1271
+ "df_sales_r[\"month\"] = pd.to_datetime(df_sales_r[\"month\"], errors=\"coerce\")\n",
1272
+ "df_sales_r[\"units_sold\"] = _safe_num(df_sales_r[\"units_sold\"])\n",
1273
+ "\n",
1274
+ "# --- Clean reviews ---\n",
1275
+ "df_reviews_r = df_reviews.copy()\n",
1276
+ "df_reviews_r[\"title\"] = df_reviews_r[\"title\"].astype(str).str.strip()\n",
1277
+ "df_reviews_r[\"sentiment_label\"] = df_reviews_r[\"sentiment_label\"].astype(str).str.lower().str.strip()\n",
1278
+ "if \"rating\" in df_reviews_r.columns:\n",
1279
+ " df_reviews_r[\"rating\"] = _safe_num(df_reviews_r[\"rating\"])\n",
1280
+ "if \"popularity_score\" in df_reviews_r.columns:\n",
1281
+ " df_reviews_r[\"popularity_score\"] = _safe_num(df_reviews_r[\"popularity_score\"])\n",
1282
+ "\n",
1283
+ "# --- Sentiment shares per title (from reviews) ---\n",
1284
+ "sent_counts = (\n",
1285
+ " df_reviews_r.groupby([\"title\", \"sentiment_label\"])\n",
1286
+ " .size()\n",
1287
+ " .unstack(fill_value=0)\n",
1288
+ ")\n",
1289
+ "for lab in [\"positive\", \"neutral\", \"negative\"]:\n",
1290
+ " if lab not in sent_counts.columns:\n",
1291
+ " sent_counts[lab] = 0\n",
1292
+ "\n",
1293
+ "sent_counts[\"total_reviews\"] = sent_counts[[\"positive\", \"neutral\", \"negative\"]].sum(axis=1)\n",
1294
+ "den = sent_counts[\"total_reviews\"].replace(0, np.nan)\n",
1295
+ "sent_counts[\"share_positive\"] = sent_counts[\"positive\"] / den\n",
1296
+ "sent_counts[\"share_neutral\"] = sent_counts[\"neutral\"] / den\n",
1297
+ "sent_counts[\"share_negative\"] = sent_counts[\"negative\"] / den\n",
1298
+ "sent_counts = sent_counts.reset_index()\n",
1299
+ "\n",
1300
+ "# --- Sales aggregation per title ---\n",
1301
+ "sales_by_title = (\n",
1302
+ " df_sales_r.dropna(subset=[\"title\"])\n",
1303
+ " .groupby(\"title\", as_index=False)\n",
1304
+ " .agg(\n",
1305
+ " months_observed=(\"month\", \"nunique\"),\n",
1306
+ " avg_units_sold=(\"units_sold\", \"mean\"),\n",
1307
+ " total_units_sold=(\"units_sold\", \"sum\"),\n",
1308
+ " )\n",
1309
+ ")\n",
1310
+ "\n",
1311
+ "# --- Title-level features (join sales + books + sentiment) ---\n",
1312
+ "df_title = (\n",
1313
+ " sales_by_title\n",
1314
+ " .merge(df_books_r[[\"title\", \"price\", \"rating\"]], on=\"title\", how=\"left\")\n",
1315
+ " .merge(sent_counts[[\"title\", \"share_positive\", \"share_neutral\", \"share_negative\", \"total_reviews\"]],\n",
1316
+ " on=\"title\", how=\"left\")\n",
1317
+ ")\n",
1318
+ "\n",
1319
+ "df_title[\"avg_revenue\"] = df_title[\"avg_units_sold\"] * df_title[\"price\"]\n",
1320
+ "df_title[\"total_revenue\"] = df_title[\"total_units_sold\"] * df_title[\"price\"]\n",
1321
+ "\n",
1322
+ "df_title.to_csv(\"synthetic_title_level_features.csv\", index=False)\n",
1323
+ "print(\"βœ… Wrote synthetic_title_level_features.csv\")\n",
1324
+ "\n",
1325
+ "# --- Monthly revenue series (proxy: units_sold * price) ---\n",
1326
+ "monthly_rev = (\n",
1327
+ " df_sales_r.merge(df_books_r[[\"title\", \"price\"]], on=\"title\", how=\"left\")\n",
1328
+ ")\n",
1329
+ "monthly_rev[\"revenue\"] = monthly_rev[\"units_sold\"] * monthly_rev[\"price\"]\n",
1330
+ "\n",
1331
+ "df_monthly = (\n",
1332
+ " monthly_rev.dropna(subset=[\"month\"])\n",
1333
+ " .groupby(\"month\", as_index=False)[\"revenue\"]\n",
1334
+ " .sum()\n",
1335
+ " .rename(columns={\"revenue\": \"total_revenue\"})\n",
1336
+ " .sort_values(\"month\")\n",
1337
+ ")\n",
1338
+ "# if revenue is all NA (e.g., missing price), fallback to units_sold as a teaching proxy\n",
1339
+ "if df_monthly[\"total_revenue\"].notna().sum() == 0:\n",
1340
+ " df_monthly = (\n",
1341
+ " df_sales_r.dropna(subset=[\"month\"])\n",
1342
+ " .groupby(\"month\", as_index=False)[\"units_sold\"]\n",
1343
+ " .sum()\n",
1344
+ " .rename(columns={\"units_sold\": \"total_revenue\"})\n",
1345
+ " .sort_values(\"month\")\n",
1346
+ " )\n",
1347
+ "\n",
1348
+ "df_monthly[\"month\"] = pd.to_datetime(df_monthly[\"month\"], errors=\"coerce\").dt.strftime(\"%Y-%m-%d\")\n",
1349
+ "df_monthly.to_csv(\"synthetic_monthly_revenue_series.csv\", index=False)\n",
1350
+ "print(\"βœ… Wrote synthetic_monthly_revenue_series.csv\")\n"
1351
+ ]
1352
+ },
1353
+ {
1354
+ "cell_type": "markdown",
1355
+ "metadata": {
1356
+ "id": "RYvGyVfXuo54"
1357
+ },
1358
+ "source": [
1359
+ "### *d. βœ‹πŸ»πŸ›‘β›”οΈ View the first few lines*"
1360
+ ]
1361
+ },
1362
+ {
1363
+ "cell_type": "code",
1364
+ "execution_count": null,
1365
+ "metadata": {
1366
+ "colab": {
1367
+ "base_uri": "https://localhost:8080/"
1368
+ },
1369
+ "id": "xfE8NMqOurKo",
1370
+ "outputId": "191730ba-d5e2-4df7-97d2-99feb0b704af"
1371
+ },
1372
+ "outputs": [
1373
+ {
1374
+ "output_type": "stream",
1375
+ "name": "stdout",
1376
+ "text": [
1377
+ " title sentiment_label \\\n",
1378
+ "0 A Light in the Attic neutral \n",
1379
+ "1 A Light in the Attic neutral \n",
1380
+ "2 A Light in the Attic neutral \n",
1381
+ "3 A Light in the Attic neutral \n",
1382
+ "4 A Light in the Attic neutral \n",
1383
+ "\n",
1384
+ " review_text rating popularity_score \n",
1385
+ "0 Had potential that went unrealized. Three 3 \n",
1386
+ "1 The themes were solid, but not well explored. Three 3 \n",
1387
+ "2 It simply lacked that emotional punch. Three 3 \n",
1388
+ "3 Serviceable but not something I'd go out of my... Three 3 \n",
1389
+ "4 Standard fare with some promise. Three 3 \n"
1390
+ ]
1391
+ }
1392
+ ],
1393
+ "source": []
1394
+ }
1395
+ ],
1396
+ "metadata": {
1397
+ "colab": {
1398
+ "collapsed_sections": [
1399
+ "jpASMyIQMaAq",
1400
+ "lquNYCbfL9IM",
1401
+ "0IWuNpxxYDJF",
1402
+ "oCdTsin2Yfp3",
1403
+ "T0TOeRC4Yrnn",
1404
+ "duI5dv3CZYvF",
1405
+ "qMjRKMBQZlJi",
1406
+ "p-1Pr2szaqLk",
1407
+ "SIaJUGIpaH4V",
1408
+ "pY4yCoIuaQqp",
1409
+ "n4-TaNTFgPak",
1410
+ "HnngRNTgacYt",
1411
+ "HF9F9HIzgT7Z",
1412
+ "T8AdKkmASq9a",
1413
+ "OhXbdGD5fH0c",
1414
+ "L2ak1HlcgoTe",
1415
+ "4IXZKcCSgxnq",
1416
+ "EhIjz9WohAmZ",
1417
+ "Gi4y9M9KuDWx",
1418
+ "fQhfVaDmuULT",
1419
+ "bmJMXF-Bukdm",
1420
+ "RYvGyVfXuo54"
1421
+ ],
1422
+ "provenance": []
1423
+ },
1424
+ "kernelspec": {
1425
+ "display_name": "Python 3",
1426
+ "name": "python3"
1427
+ },
1428
+ "language_info": {
1429
+ "name": "python"
1430
+ }
1431
+ },
1432
+ "nbformat": 4,
1433
+ "nbformat_minor": 0
1434
+ }
2a_Python_Analysis- TESLER (1).ipynb ADDED
The diff for this file is too large to render. See raw diff