veravf/hands-on-activity-5
0
1{2 "cells": [3 {4 "cell_type": "markdown",5 "metadata": {6 "id": "kz8lLSv6mVQo"7 },8 "source": [9 "# **๐ค Data Analysis & Visualization**"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": 1,24 "metadata": {25 "colab": {26 "base_uri": "https://localhost:8080/"27 },28 "id": "f48c8f8c",29 "outputId": "ca8b5ef6-ebc4-4fc6-9373-e1577253fd21"30 },31 "outputs": [32 {33 "output_type": "stream",34 "name": "stdout",35 "text": [36 "Requirement already satisfied: pandas in /usr/local/lib/python3.12/dist-packages (2.2.2)\n",37 "Requirement already satisfied: matplotlib in /usr/local/lib/python3.12/dist-packages (3.10.0)\n",38 "Requirement already satisfied: seaborn in /usr/local/lib/python3.12/dist-packages (0.13.2)\n",39 "Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (2.0.2)\n",40 "Requirement already satisfied: textblob in /usr/local/lib/python3.12/dist-packages (0.19.0)\n",41 "Collecting faker\n",42 " Downloading faker-40.4.0-py3-none-any.whl.metadata (16 kB)\n",43 "Requirement already satisfied: transformers in /usr/local/lib/python3.12/dist-packages (5.0.0)\n",44 "Collecting vaderSentiment\n",45 " Downloading vaderSentiment-3.3.2-py2.py3-none-any.whl.metadata (572 bytes)\n",46 "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.9.0.post0)\n",47 "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",48 "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.3)\n",49 "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.3.3)\n",50 "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (0.12.1)\n",51 "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (4.61.1)\n",52 "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.4.9)\n",53 "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (26.0)\n",54 "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (11.3.0)\n",55 "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (3.3.2)\n",56 "Requirement already satisfied: nltk>=3.9 in /usr/local/lib/python3.12/dist-packages (from textblob) (3.9.1)\n",57 "Requirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from transformers) (3.20.3)\n",58 "Requirement already satisfied: huggingface-hub<2.0,>=1.3.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (1.4.0)\n",59 "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from transformers) (6.0.3)\n",60 "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.12/dist-packages (from transformers) (2025.11.3)\n",61 "Requirement already satisfied: tokenizers<=0.23.0,>=0.22.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.22.2)\n",62 "Requirement already satisfied: typer-slim in /usr/local/lib/python3.12/dist-packages (from transformers) (0.21.1)\n",63 "Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.7.0)\n",64 "Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.12/dist-packages (from transformers) (4.67.3)\n",65 "Requirement already satisfied: requests in /usr/local/lib/python3.12/dist-packages (from vaderSentiment) (2.32.4)\n",66 "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.3.0->transformers) (2025.3.0)\n",67 "Requirement already satisfied: hf-xet<2.0.0,>=1.2.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.3.0->transformers) (1.2.0)\n",68 "Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.3.0->transformers) (0.28.1)\n",69 "Requirement already satisfied: shellingham in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.3.0->transformers) (1.5.4)\n",70 "Requirement already satisfied: typing-extensions>=4.1.0 in /usr/local/lib/python3.12/dist-packages (from huggingface-hub<2.0,>=1.3.0->transformers) (4.15.0)\n",71 "Requirement already satisfied: click in /usr/local/lib/python3.12/dist-packages (from nltk>=3.9->textblob) (8.3.1)\n",72 "Requirement already satisfied: joblib in /usr/local/lib/python3.12/dist-packages (from nltk>=3.9->textblob) (1.5.3)\n",73 "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",74 "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests->vaderSentiment) (3.4.4)\n",75 "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests->vaderSentiment) (3.11)\n",76 "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests->vaderSentiment) (2.5.0)\n",77 "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests->vaderSentiment) (2026.1.4)\n",78 "Requirement already satisfied: anyio in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.3.0->transformers) (4.12.1)\n",79 "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.12/dist-packages (from httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.3.0->transformers) (1.0.9)\n",80 "Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.12/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->huggingface-hub<2.0,>=1.3.0->transformers) (0.16.0)\n",81 "Downloading faker-40.4.0-py3-none-any.whl (2.0 MB)\n",82 "\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m23.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",83 "\u001b[?25hDownloading vaderSentiment-3.3.2-py2.py3-none-any.whl (125 kB)\n",84 "\u001b[2K \u001b[90mโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\u001b[0m \u001b[32m126.0/126.0 kB\u001b[0m \u001b[31m11.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",85 "\u001b[?25hInstalling collected packages: faker, vaderSentiment\n",86 "Successfully installed faker-40.4.0 vaderSentiment-3.3.2\n"87 ]88 }89 ],90 "source": [91 "!pip install pandas matplotlib seaborn numpy textblob faker transformers vaderSentiment\n"92 ]93 },94 {95 "cell_type": "markdown",96 "metadata": {97 "id": "NZd99NpKkKyp"98 },99 "source": [100 "## **2.** โ
๏ธ Load & inspect input datasets"101 ]102 },103 {104 "cell_type": "markdown",105 "metadata": {106 "id": "_JBLmm508Uq2"107 },108 "source": [109 "### *a. Initial setup*"110 ]111 },112 {113 "cell_type": "code",114 "execution_count": 2,115 "metadata": {116 "id": "eBDXPQz18Xrs"117 },118 "outputs": [],119 "source": [120 "import pandas as pd\n",121 "import numpy as np\n",122 "import random"123 ]124 },125 {126 "cell_type": "markdown",127 "metadata": {128 "id": "IL8lZbMm8m3k"129 },130 "source": [131 "### *b. โ๐ป๐โ๏ธ Create the df_reviews dataframe from the synthetic_book_reviews.csv file*"132 ]133 },134 {135 "cell_type": "code",136 "execution_count": 3,137 "metadata": {138 "id": "fdgjghfO8uuq"139 },140 "outputs": [],141 "source": [142 "df_reviews = pd.read_csv(\"synthetic_book_reviews.csv\")"143 ]144 },145 {146 "cell_type": "markdown",147 "metadata": {148 "id": "N-Dl37J0HLhU"149 },150 "source": [151 "### *c. โ๐ป๐โ๏ธ Create the df_sales dataframe from the synthetic_sales_data.csv file*"152 ]153 },154 {155 "cell_type": "code",156 "execution_count": 4,157 "metadata": {158 "id": "6XZs3P7fHgQe"159 },160 "outputs": [],161 "source": [162 "df_sales = pd.read_csv(\"synthetic_sales_data.csv\")"163 ]164 },165 {166 "cell_type": "markdown",167 "metadata": {168 "id": "MUI3SkmyrGQo"169 },170 "source": [171 "### *d. โ๐ป๐โ๏ธ Visualize the first few lines of the two final datasets: df_reviews and df_sales*"172 ]173 },174 {175 "cell_type": "code",176 "execution_count": 5,177 "metadata": {178 "colab": {179 "base_uri": "https://localhost:8080/"180 },181 "id": "p8FdQFXErOqE",182 "outputId": "b6673cc0-bb1d-4221-dcef-e1f9dec0d6c8"183 },184 "outputs": [185 {186 "output_type": "stream",187 "name": "stdout",188 "text": [189 " title month units_sold sentiment_label\n",190 "0 A Light in the Attic 2024-08 100 neutral\n",191 "1 A Light in the Attic 2024-09 109 neutral\n",192 "2 A Light in the Attic 2024-10 102 neutral\n",193 "3 A Light in the Attic 2024-11 107 neutral\n",194 "4 A Light in the Attic 2024-12 108 neutral\n",195 " title sentiment_label \\\n",196 "0 A Light in the Attic neutral \n",197 "1 A Light in the Attic neutral \n",198 "2 A Light in the Attic neutral \n",199 "3 A Light in the Attic neutral \n",200 "4 A Light in the Attic neutral \n",201 "\n",202 " review_text rating popularity_score \n",203 "0 Had potential that went unrealized. Three 3 \n",204 "1 The themes were solid, but not well explored. Three 3 \n",205 "2 It simply lacked that emotional punch. Three 3 \n",206 "3 Serviceable but not something I'd go out of my... Three 3 \n",207 "4 Standard fare with some promise. Three 3 \n"208 ]209 }210 ],211 "source": [212 "print(df_sales.head())\n",213 "print(df_reviews.head())"214 ]215 },216 {217 "cell_type": "markdown",218 "metadata": {219 "id": "Y3oqGHsmrQzx"220 },221 "source": [222 "### *d. Run a quality check on the datasets*"223 ]224 },225 {226 "cell_type": "code",227 "execution_count": 6,228 "metadata": {229 "colab": {230 "base_uri": "https://localhost:8080/",231 "height": 1000232 },233 "id": "VArQGPoKrfLm",234 "outputId": "16e94f18-4f60-44ba-919e-fc129f7f440e"235 },236 "outputs": [237 {238 "output_type": "stream",239 "name": "stdout",240 "text": [241 "\n",242 "๐ Quality Check Report for: df_reviews\n",243 "===================================\n",244 "\n",245 "๐ Shape: (10000, 5)\n",246 "\n",247 "๐ Column Types:\n",248 "title object\n",249 "sentiment_label object\n",250 "review_text object\n",251 "rating object\n",252 "popularity_score int64\n",253 "dtype: object\n",254 "\n",255 "โ Missing Values:\n",256 "title 0\n",257 "sentiment_label 0\n",258 "review_text 0\n",259 "rating 0\n",260 "popularity_score 0\n",261 "dtype: int64\n",262 "\n",263 "๐ Duplicate Rows: 0\n",264 "\n",265 "๐ Summary Statistics:\n"266 ]267 },268 {269 "output_type": "display_data",270 "data": {271 "text/plain": [272 " count unique \\\n",273 "title 10000 999 \n",274 "sentiment_label 10000 3 \n",275 "review_text 10000 149 \n",276 "rating 10000 5 \n",277 "popularity_score 10000.0 NaN \n",278 "\n",279 " top freq \\\n",280 "title The Star-Touched Queen 20 \n",281 "sentiment_label positive 4380 \n",282 "review_text A thought-provoking journey with stunning char... 112 \n",283 "rating One 2260 \n",284 "popularity_score NaN NaN \n",285 "\n",286 " mean std min 25% 50% 75% max \n",287 "title NaN NaN NaN NaN NaN NaN NaN \n",288 "sentiment_label NaN NaN NaN NaN NaN NaN NaN \n",289 "review_text NaN NaN NaN NaN NaN NaN NaN \n",290 "rating NaN NaN NaN NaN NaN NaN NaN \n",291 "popularity_score 3.282 1.028874 1.0 3.0 3.0 4.0 5.0 "292 ],293 "text/html": [294 "\n",295 " <div id=\"df-99a09da9-b058-462b-a3d8-cbc3ad600d29\" class=\"colab-df-container\">\n",296 " <div>\n",297 "<style scoped>\n",298 " .dataframe tbody tr th:only-of-type {\n",299 " vertical-align: middle;\n",300 " }\n",301 "\n",302 " .dataframe tbody tr th {\n",303 " vertical-align: top;\n",304 " }\n",305 "\n",306 " .dataframe thead th {\n",307 " text-align: right;\n",308 " }\n",309 "</style>\n",310 "<table border=\"1\" class=\"dataframe\">\n",311 " <thead>\n",312 " <tr style=\"text-align: right;\">\n",313 " <th></th>\n",314 " <th>count</th>\n",315 " <th>unique</th>\n",316 " <th>top</th>\n",317 " <th>freq</th>\n",318 " <th>mean</th>\n",319 " <th>std</th>\n",320 " <th>min</th>\n",321 " <th>25%</th>\n",322 " <th>50%</th>\n",323 " <th>75%</th>\n",324 " <th>max</th>\n",325 " </tr>\n",326 " </thead>\n",327 " <tbody>\n",328 " <tr>\n",329 " <th>title</th>\n",330 " <td>10000</td>\n",331 " <td>999</td>\n",332 " <td>The Star-Touched Queen</td>\n",333 " <td>20</td>\n",334 " <td>NaN</td>\n",335 " <td>NaN</td>\n",336 " <td>NaN</td>\n",337 " <td>NaN</td>\n",338 " <td>NaN</td>\n",339 " <td>NaN</td>\n",340 " <td>NaN</td>\n",341 " </tr>\n",342 " <tr>\n",343 " <th>sentiment_label</th>\n",344 " <td>10000</td>\n",345 " <td>3</td>\n",346 " <td>positive</td>\n",347 " <td>4380</td>\n",348 " <td>NaN</td>\n",349 " <td>NaN</td>\n",350 " <td>NaN</td>\n",351 " <td>NaN</td>\n",352 " <td>NaN</td>\n",353 " <td>NaN</td>\n",354 " <td>NaN</td>\n",355 " </tr>\n",356 " <tr>\n",357 " <th>review_text</th>\n",358 " <td>10000</td>\n",359 " <td>149</td>\n",360 " <td>A thought-provoking journey with stunning char...</td>\n",361 " <td>112</td>\n",362 " <td>NaN</td>\n",363 " <td>NaN</td>\n",364 " <td>NaN</td>\n",365 " <td>NaN</td>\n",366 " <td>NaN</td>\n",367 " <td>NaN</td>\n",368 " <td>NaN</td>\n",369 " </tr>\n",370 " <tr>\n",371 " <th>rating</th>\n",372 " <td>10000</td>\n",373 " <td>5</td>\n",374 " <td>One</td>\n",375 " <td>2260</td>\n",376 " <td>NaN</td>\n",377 " <td>NaN</td>\n",378 " <td>NaN</td>\n",379 " <td>NaN</td>\n",380 " <td>NaN</td>\n",381 " <td>NaN</td>\n",382 " <td>NaN</td>\n",383 " </tr>\n",384 " <tr>\n",385 " <th>popularity_score</th>\n",386 " <td>10000.0</td>\n",387 " <td>NaN</td>\n",388 " <td>NaN</td>\n",389 " <td>NaN</td>\n",390 " <td>3.282</td>\n",391 " <td>1.028874</td>\n",392 " <td>1.0</td>\n",393 " <td>3.0</td>\n",394 " <td>3.0</td>\n",395 " <td>4.0</td>\n",396 " <td>5.0</td>\n",397 " </tr>\n",398 " </tbody>\n",399 "</table>\n",400 "</div>\n",401 " <div class=\"colab-df-buttons\">\n",402 "\n",403 " <div class=\"colab-df-container\">\n",404 " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-99a09da9-b058-462b-a3d8-cbc3ad600d29')\"\n",405 " title=\"Convert this dataframe to an interactive table.\"\n",406 " style=\"display:none;\">\n",407 "\n",408 " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",409 " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",410 " </svg>\n",411 " </button>\n",412 "\n",413 " <style>\n",414 " .colab-df-container {\n",415 " display:flex;\n",416 " gap: 12px;\n",417 " }\n",418 "\n",419 " .colab-df-convert {\n",420 " background-color: #E8F0FE;\n",421 " border: none;\n",422 " border-radius: 50%;\n",423 " cursor: pointer;\n",424 " display: none;\n",425 " fill: #1967D2;\n",426 " height: 32px;\n",427 " padding: 0 0 0 0;\n",428 " width: 32px;\n",429 " }\n",430 "\n",431 " .colab-df-convert:hover {\n",432 " background-color: #E2EBFA;\n",433 " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",434 " fill: #174EA6;\n",435 " }\n",436 "\n",437 " .colab-df-buttons div {\n",438 " margin-bottom: 4px;\n",439 " }\n",440 "\n",441 " [theme=dark] .colab-df-convert {\n",442 " background-color: #3B4455;\n",443 " fill: #D2E3FC;\n",444 " }\n",445 "\n",446 " [theme=dark] .colab-df-convert:hover {\n",447 " background-color: #434B5C;\n",448 " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",449 " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",450 " fill: #FFFFFF;\n",451 " }\n",452 " </style>\n",453 "\n",454 " <script>\n",455 " const buttonEl =\n",456 " document.querySelector('#df-99a09da9-b058-462b-a3d8-cbc3ad600d29 button.colab-df-convert');\n",457 " buttonEl.style.display =\n",458 " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",459 "\n",460 " async function convertToInteractive(key) {\n",461 " const element = document.querySelector('#df-99a09da9-b058-462b-a3d8-cbc3ad600d29');\n",462 " const dataTable =\n",463 " await google.colab.kernel.invokeFunction('convertToInteractive',\n",464 " [key], {});\n",465 " if (!dataTable) return;\n",466 "\n",467 " const docLinkHtml = 'Like what you see? Visit the ' +\n",468 " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",469 " + ' to learn more about interactive tables.';\n",470 " element.innerHTML = '';\n",471 " dataTable['output_type'] = 'display_data';\n",472 " await google.colab.output.renderOutput(dataTable, element);\n",473 " const docLink = document.createElement('div');\n",474 " docLink.innerHTML = docLinkHtml;\n",475 " element.appendChild(docLink);\n",476 " }\n",477 " </script>\n",478 " </div>\n",479 "\n",480 "\n",481 " </div>\n",482 " </div>\n"483 ],484 "application/vnd.google.colaboratory.intrinsic+json": {485 "type": "dataframe",486 "summary": "{\n \"name\": \"quality_check(df_sales, \\\"df_sales\\\")\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"count\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"10000\",\n \"max\": \"10000\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"10000\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"unique\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 3,\n \"max\": 999,\n \"num_unique_values\": 4,\n \"samples\": [\n 3\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"top\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"positive\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"freq\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"20\",\n \"max\": \"4380\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"4380\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"mean\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 3.282,\n \"max\": 3.282,\n \"num_unique_values\": 1,\n \"samples\": [\n 3.282\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"std\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 1.0288740730458223,\n \"max\": 1.0288740730458223,\n \"num_unique_values\": 1,\n \"samples\": [\n 1.0288740730458223\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"min\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 1.0,\n \"max\": 1.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 1.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"25%\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 3.0,\n \"max\": 3.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 3.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"50%\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 3.0,\n \"max\": 3.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 3.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"75%\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 4.0,\n \"max\": 4.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 4.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"max\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 5.0,\n \"max\": 5.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 5.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"487 }488 },489 "metadata": {}490 },491 {492 "output_type": "stream",493 "name": "stdout",494 "text": [495 "\n",496 "๐ Sample Rows:\n"497 ]498 },499 {500 "output_type": "display_data",501 "data": {502 "text/plain": [503 " title sentiment_label \\\n",504 "479 Untitled Collection: Sabbath Poems 2014 positive \n",505 "5601 The Barefoot Contessa Cookbook neutral \n",506 "9468 Sister Sable (The Mad Queen #1) neutral \n",507 "8116 Life, the Universe and Everything (Hitchhiker'... positive \n",508 "2372 The Songs of the Gods positive \n",509 "\n",510 " review_text rating \\\n",511 "479 Both epic and intimate โ a perfect balance. Four \n",512 "5601 A safe, inoffensive choice. Five \n",513 "9468 There was a spark, but it didnโt ignite. Three \n",514 "8116 Left me smiling, teary-eyed, and completely fu... Two \n",515 "2372 A thought-provoking journey with stunning char... Five \n",516 "\n",517 " popularity_score \n",518 "479 4 \n",519 "5601 3 \n",520 "9468 3 \n",521 "8116 4 \n",522 "2372 4 "523 ],524 "text/html": [525 "\n",526 " <div id=\"df-0871ec7a-211d-4cb6-800c-ced1ab8286bb\" class=\"colab-df-container\">\n",527 " <div>\n",528 "<style scoped>\n",529 " .dataframe tbody tr th:only-of-type {\n",530 " vertical-align: middle;\n",531 " }\n",532 "\n",533 " .dataframe tbody tr th {\n",534 " vertical-align: top;\n",535 " }\n",536 "\n",537 " .dataframe thead th {\n",538 " text-align: right;\n",539 " }\n",540 "</style>\n",541 "<table border=\"1\" class=\"dataframe\">\n",542 " <thead>\n",543 " <tr style=\"text-align: right;\">\n",544 " <th></th>\n",545 " <th>title</th>\n",546 " <th>sentiment_label</th>\n",547 " <th>review_text</th>\n",548 " <th>rating</th>\n",549 " <th>popularity_score</th>\n",550 " </tr>\n",551 " </thead>\n",552 " <tbody>\n",553 " <tr>\n",554 " <th>479</th>\n",555 " <td>Untitled Collection: Sabbath Poems 2014</td>\n",556 " <td>positive</td>\n",557 " <td>Both epic and intimate โ a perfect balance.</td>\n",558 " <td>Four</td>\n",559 " <td>4</td>\n",560 " </tr>\n",561 " <tr>\n",562 " <th>5601</th>\n",563 " <td>The Barefoot Contessa Cookbook</td>\n",564 " <td>neutral</td>\n",565 " <td>A safe, inoffensive choice.</td>\n",566 " <td>Five</td>\n",567 " <td>3</td>\n",568 " </tr>\n",569 " <tr>\n",570 " <th>9468</th>\n",571 " <td>Sister Sable (The Mad Queen #1)</td>\n",572 " <td>neutral</td>\n",573 " <td>There was a spark, but it didnโt ignite.</td>\n",574 " <td>Three</td>\n",575 " <td>3</td>\n",576 " </tr>\n",577 " <tr>\n",578 " <th>8116</th>\n",579 " <td>Life, the Universe and Everything (Hitchhiker'...</td>\n",580 " <td>positive</td>\n",581 " <td>Left me smiling, teary-eyed, and completely fu...</td>\n",582 " <td>Two</td>\n",583 " <td>4</td>\n",584 " </tr>\n",585 " <tr>\n",586 " <th>2372</th>\n",587 " <td>The Songs of the Gods</td>\n",588 " <td>positive</td>\n",589 " <td>A thought-provoking journey with stunning char...</td>\n",590 " <td>Five</td>\n",591 " <td>4</td>\n",592 " </tr>\n",593 " </tbody>\n",594 "</table>\n",595 "</div>\n",596 " <div class=\"colab-df-buttons\">\n",597 "\n",598 " <div class=\"colab-df-container\">\n",599 " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-0871ec7a-211d-4cb6-800c-ced1ab8286bb')\"\n",600 " title=\"Convert this dataframe to an interactive table.\"\n",601 " style=\"display:none;\">\n",602 "\n",603 " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",604 " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",605 " </svg>\n",606 " </button>\n",607 "\n",608 " <style>\n",609 " .colab-df-container {\n",610 " display:flex;\n",611 " gap: 12px;\n",612 " }\n",613 "\n",614 " .colab-df-convert {\n",615 " background-color: #E8F0FE;\n",616 " border: none;\n",617 " border-radius: 50%;\n",618 " cursor: pointer;\n",619 " display: none;\n",620 " fill: #1967D2;\n",621 " height: 32px;\n",622 " padding: 0 0 0 0;\n",623 " width: 32px;\n",624 " }\n",625 "\n",626 " .colab-df-convert:hover {\n",627 " background-color: #E2EBFA;\n",628 " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",629 " fill: #174EA6;\n",630 " }\n",631 "\n",632 " .colab-df-buttons div {\n",633 " margin-bottom: 4px;\n",634 " }\n",635 "\n",636 " [theme=dark] .colab-df-convert {\n",637 " background-color: #3B4455;\n",638 " fill: #D2E3FC;\n",639 " }\n",640 "\n",641 " [theme=dark] .colab-df-convert:hover {\n",642 " background-color: #434B5C;\n",643 " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",644 " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",645 " fill: #FFFFFF;\n",646 " }\n",647 " </style>\n",648 "\n",649 " <script>\n",650 " const buttonEl =\n",651 " document.querySelector('#df-0871ec7a-211d-4cb6-800c-ced1ab8286bb button.colab-df-convert');\n",652 " buttonEl.style.display =\n",653 " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",654 "\n",655 " async function convertToInteractive(key) {\n",656 " const element = document.querySelector('#df-0871ec7a-211d-4cb6-800c-ced1ab8286bb');\n",657 " const dataTable =\n",658 " await google.colab.kernel.invokeFunction('convertToInteractive',\n",659 " [key], {});\n",660 " if (!dataTable) return;\n",661 "\n",662 " const docLinkHtml = 'Like what you see? Visit the ' +\n",663 " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",664 " + ' to learn more about interactive tables.';\n",665 " element.innerHTML = '';\n",666 " dataTable['output_type'] = 'display_data';\n",667 " await google.colab.output.renderOutput(dataTable, element);\n",668 " const docLink = document.createElement('div');\n",669 " docLink.innerHTML = docLinkHtml;\n",670 " element.appendChild(docLink);\n",671 " }\n",672 " </script>\n",673 " </div>\n",674 "\n",675 "\n",676 " </div>\n",677 " </div>\n"678 ],679 "application/vnd.google.colaboratory.intrinsic+json": {680 "type": "dataframe",681 "summary": "{\n \"name\": \"quality_check(df_sales, \\\"df_sales\\\")\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"The Barefoot Contessa Cookbook\",\n \"The Songs of the Gods\",\n \"Sister Sable (The Mad Queen #1)\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"sentiment_label\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"neutral\",\n \"positive\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"review_text\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"A safe, inoffensive choice.\",\n \"A thought-provoking journey with stunning character development.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"Five\",\n \"Two\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"popularity_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 3,\n \"max\": 4,\n \"num_unique_values\": 2,\n \"samples\": [\n 3,\n 4\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"682 }683 },684 "metadata": {}685 },686 {687 "output_type": "stream",688 "name": "stdout",689 "text": [690 "\n",691 "๐ Quality Check Report for: df_sales\n",692 "=================================\n",693 "\n",694 "๐ Shape: (18000, 4)\n",695 "\n",696 "๐ Column Types:\n",697 "title object\n",698 "month object\n",699 "units_sold int64\n",700 "sentiment_label object\n",701 "dtype: object\n",702 "\n",703 "โ Missing Values:\n",704 "title 0\n",705 "month 0\n",706 "units_sold 0\n",707 "sentiment_label 0\n",708 "dtype: int64\n",709 "\n",710 "๐ Duplicate Rows: 0\n",711 "\n",712 "๐ Summary Statistics:\n"713 ]714 },715 {716 "output_type": "display_data",717 "data": {718 "text/plain": [719 " count unique top freq mean \\\n",720 "title 18000 999 The Star-Touched Queen 36 NaN \n",721 "month 18000 18 2024-08 1000 NaN \n",722 "units_sold 18000.0 NaN NaN NaN 168.024167 \n",723 "sentiment_label 18000 3 positive 7884 NaN \n",724 "\n",725 " std min 25% 50% 75% max \n",726 "title NaN NaN NaN NaN NaN NaN \n",727 "month NaN NaN NaN NaN NaN NaN \n",728 "units_sold 98.656354 0.0 84.0 148.0 262.0 362.0 \n",729 "sentiment_label NaN NaN NaN NaN NaN NaN "730 ],731 "text/html": [732 "\n",733 " <div id=\"df-abd4878f-5cb7-4f25-a368-11c802578f50\" class=\"colab-df-container\">\n",734 " <div>\n",735 "<style scoped>\n",736 " .dataframe tbody tr th:only-of-type {\n",737 " vertical-align: middle;\n",738 " }\n",739 "\n",740 " .dataframe tbody tr th {\n",741 " vertical-align: top;\n",742 " }\n",743 "\n",744 " .dataframe thead th {\n",745 " text-align: right;\n",746 " }\n",747 "</style>\n",748 "<table border=\"1\" class=\"dataframe\">\n",749 " <thead>\n",750 " <tr style=\"text-align: right;\">\n",751 " <th></th>\n",752 " <th>count</th>\n",753 " <th>unique</th>\n",754 " <th>top</th>\n",755 " <th>freq</th>\n",756 " <th>mean</th>\n",757 " <th>std</th>\n",758 " <th>min</th>\n",759 " <th>25%</th>\n",760 " <th>50%</th>\n",761 " <th>75%</th>\n",762 " <th>max</th>\n",763 " </tr>\n",764 " </thead>\n",765 " <tbody>\n",766 " <tr>\n",767 " <th>title</th>\n",768 " <td>18000</td>\n",769 " <td>999</td>\n",770 " <td>The Star-Touched Queen</td>\n",771 " <td>36</td>\n",772 " <td>NaN</td>\n",773 " <td>NaN</td>\n",774 " <td>NaN</td>\n",775 " <td>NaN</td>\n",776 " <td>NaN</td>\n",777 " <td>NaN</td>\n",778 " <td>NaN</td>\n",779 " </tr>\n",780 " <tr>\n",781 " <th>month</th>\n",782 " <td>18000</td>\n",783 " <td>18</td>\n",784 " <td>2024-08</td>\n",785 " <td>1000</td>\n",786 " <td>NaN</td>\n",787 " <td>NaN</td>\n",788 " <td>NaN</td>\n",789 " <td>NaN</td>\n",790 " <td>NaN</td>\n",791 " <td>NaN</td>\n",792 " <td>NaN</td>\n",793 " </tr>\n",794 " <tr>\n",795 " <th>units_sold</th>\n",796 " <td>18000.0</td>\n",797 " <td>NaN</td>\n",798 " <td>NaN</td>\n",799 " <td>NaN</td>\n",800 " <td>168.024167</td>\n",801 " <td>98.656354</td>\n",802 " <td>0.0</td>\n",803 " <td>84.0</td>\n",804 " <td>148.0</td>\n",805 " <td>262.0</td>\n",806 " <td>362.0</td>\n",807 " </tr>\n",808 " <tr>\n",809 " <th>sentiment_label</th>\n",810 " <td>18000</td>\n",811 " <td>3</td>\n",812 " <td>positive</td>\n",813 " <td>7884</td>\n",814 " <td>NaN</td>\n",815 " <td>NaN</td>\n",816 " <td>NaN</td>\n",817 " <td>NaN</td>\n",818 " <td>NaN</td>\n",819 " <td>NaN</td>\n",820 " <td>NaN</td>\n",821 " </tr>\n",822 " </tbody>\n",823 "</table>\n",824 "</div>\n",825 " <div class=\"colab-df-buttons\">\n",826 "\n",827 " <div class=\"colab-df-container\">\n",828 " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-abd4878f-5cb7-4f25-a368-11c802578f50')\"\n",829 " title=\"Convert this dataframe to an interactive table.\"\n",830 " style=\"display:none;\">\n",831 "\n",832 " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",833 " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",834 " </svg>\n",835 " </button>\n",836 "\n",837 " <style>\n",838 " .colab-df-container {\n",839 " display:flex;\n",840 " gap: 12px;\n",841 " }\n",842 "\n",843 " .colab-df-convert {\n",844 " background-color: #E8F0FE;\n",845 " border: none;\n",846 " border-radius: 50%;\n",847 " cursor: pointer;\n",848 " display: none;\n",849 " fill: #1967D2;\n",850 " height: 32px;\n",851 " padding: 0 0 0 0;\n",852 " width: 32px;\n",853 " }\n",854 "\n",855 " .colab-df-convert:hover {\n",856 " background-color: #E2EBFA;\n",857 " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",858 " fill: #174EA6;\n",859 " }\n",860 "\n",861 " .colab-df-buttons div {\n",862 " margin-bottom: 4px;\n",863 " }\n",864 "\n",865 " [theme=dark] .colab-df-convert {\n",866 " background-color: #3B4455;\n",867 " fill: #D2E3FC;\n",868 " }\n",869 "\n",870 " [theme=dark] .colab-df-convert:hover {\n",871 " background-color: #434B5C;\n",872 " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",873 " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",874 " fill: #FFFFFF;\n",875 " }\n",876 " </style>\n",877 "\n",878 " <script>\n",879 " const buttonEl =\n",880 " document.querySelector('#df-abd4878f-5cb7-4f25-a368-11c802578f50 button.colab-df-convert');\n",881 " buttonEl.style.display =\n",882 " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",883 "\n",884 " async function convertToInteractive(key) {\n",885 " const element = document.querySelector('#df-abd4878f-5cb7-4f25-a368-11c802578f50');\n",886 " const dataTable =\n",887 " await google.colab.kernel.invokeFunction('convertToInteractive',\n",888 " [key], {});\n",889 " if (!dataTable) return;\n",890 "\n",891 " const docLinkHtml = 'Like what you see? Visit the ' +\n",892 " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",893 " + ' to learn more about interactive tables.';\n",894 " element.innerHTML = '';\n",895 " dataTable['output_type'] = 'display_data';\n",896 " await google.colab.output.renderOutput(dataTable, element);\n",897 " const docLink = document.createElement('div');\n",898 " docLink.innerHTML = docLinkHtml;\n",899 " element.appendChild(docLink);\n",900 " }\n",901 " </script>\n",902 " </div>\n",903 "\n",904 "\n",905 " </div>\n",906 " </div>\n"907 ],908 "application/vnd.google.colaboratory.intrinsic+json": {909 "type": "dataframe",910 "summary": "{\n \"name\": \"quality_check(df_sales, \\\"df_sales\\\")\",\n \"rows\": 4,\n \"fields\": [\n {\n \"column\": \"count\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"18000\",\n \"max\": \"18000\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"18000\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"unique\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 3,\n \"max\": 999,\n \"num_unique_values\": 3,\n \"samples\": [\n 999\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"top\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"The Star-Touched Queen\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"freq\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"36\",\n \"max\": \"7884\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"36\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"mean\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 168.02416666666667,\n \"max\": 168.02416666666667,\n \"num_unique_values\": 1,\n \"samples\": [\n 168.02416666666667\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"std\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 98.65635350480927,\n \"max\": 98.65635350480927,\n \"num_unique_values\": 1,\n \"samples\": [\n 98.65635350480927\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"min\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 0.0,\n \"max\": 0.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 0.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"25%\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 84.0,\n \"max\": 84.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 84.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"50%\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 148.0,\n \"max\": 148.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 148.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"75%\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 262.0,\n \"max\": 262.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 262.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"max\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": 362.0,\n \"max\": 362.0,\n \"num_unique_values\": 1,\n \"samples\": [\n 362.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"911 }912 },913 "metadata": {}914 },915 {916 "output_type": "stream",917 "name": "stdout",918 "text": [919 "\n",920 "๐ Sample Rows:\n"921 ]922 },923 {924 "output_type": "display_data",925 "data": {926 "text/plain": [927 " title month units_sold \\\n",928 "5320 Island of Dragons (Unwanteds #7) 2025-06 15 \n",929 "14890 I've Got Your Number 2024-12 68 \n",930 "9029 The Origin of Species 2025-07 242 \n",931 "5598 Eaternity: More than 150 Deliciously Easy Vega... 2024-08 262 \n",932 "11930 Outlander (Outlander #1) 2025-10 338 \n",933 "\n",934 " sentiment_label \n",935 "5320 negative \n",936 "14890 negative \n",937 "9029 positive \n",938 "5598 positive \n",939 "11930 positive "940 ],941 "text/html": [942 "\n",943 " <div id=\"df-f4c00acf-abbd-4ebd-b11b-431f15daf928\" class=\"colab-df-container\">\n",944 " <div>\n",945 "<style scoped>\n",946 " .dataframe tbody tr th:only-of-type {\n",947 " vertical-align: middle;\n",948 " }\n",949 "\n",950 " .dataframe tbody tr th {\n",951 " vertical-align: top;\n",952 " }\n",953 "\n",954 " .dataframe thead th {\n",955 " text-align: right;\n",956 " }\n",957 "</style>\n",958 "<table border=\"1\" class=\"dataframe\">\n",959 " <thead>\n",960 " <tr style=\"text-align: right;\">\n",961 " <th></th>\n",962 " <th>title</th>\n",963 " <th>month</th>\n",964 " <th>units_sold</th>\n",965 " <th>sentiment_label</th>\n",966 " </tr>\n",967 " </thead>\n",968 " <tbody>\n",969 " <tr>\n",970 " <th>5320</th>\n",971 " <td>Island of Dragons (Unwanteds #7)</td>\n",972 " <td>2025-06</td>\n",973 " <td>15</td>\n",974 " <td>negative</td>\n",975 " </tr>\n",976 " <tr>\n",977 " <th>14890</th>\n",978 " <td>I've Got Your Number</td>\n",979 " <td>2024-12</td>\n",980 " <td>68</td>\n",981 " <td>negative</td>\n",982 " </tr>\n",983 " <tr>\n",984 " <th>9029</th>\n",985 " <td>The Origin of Species</td>\n",986 " <td>2025-07</td>\n",987 " <td>242</td>\n",988 " <td>positive</td>\n",989 " </tr>\n",990 " <tr>\n",991 " <th>5598</th>\n",992 " <td>Eaternity: More than 150 Deliciously Easy Vega...</td>\n",993 " <td>2024-08</td>\n",994 " <td>262</td>\n",995 " <td>positive</td>\n",996 " </tr>\n",997 " <tr>\n",998 " <th>11930</th>\n",999 " <td>Outlander (Outlander #1)</td>\n",1000 " <td>2025-10</td>\n",1001 " <td>338</td>\n",1002 " <td>positive</td>\n",1003 " </tr>\n",1004 " </tbody>\n",1005 "</table>\n",1006 "</div>\n",1007 " <div class=\"colab-df-buttons\">\n",1008 "\n",1009 " <div class=\"colab-df-container\">\n",1010 " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-f4c00acf-abbd-4ebd-b11b-431f15daf928')\"\n",1011 " title=\"Convert this dataframe to an interactive table.\"\n",1012 " style=\"display:none;\">\n",1013 "\n",1014 " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",1015 " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",1016 " </svg>\n",1017 " </button>\n",1018 "\n",1019 " <style>\n",1020 " .colab-df-container {\n",1021 " display:flex;\n",1022 " gap: 12px;\n",1023 " }\n",1024 "\n",1025 " .colab-df-convert {\n",1026 " background-color: #E8F0FE;\n",1027 " border: none;\n",1028 " border-radius: 50%;\n",1029 " cursor: pointer;\n",1030 " display: none;\n",1031 " fill: #1967D2;\n",1032 " height: 32px;\n",1033 " padding: 0 0 0 0;\n",1034 " width: 32px;\n",1035 " }\n",1036 "\n",1037 " .colab-df-convert:hover {\n",1038 " background-color: #E2EBFA;\n",1039 " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",1040 " fill: #174EA6;\n",1041 " }\n",1042 "\n",1043 " .colab-df-buttons div {\n",1044 " margin-bottom: 4px;\n",1045 " }\n",1046 "\n",1047 " [theme=dark] .colab-df-convert {\n",1048 " background-color: #3B4455;\n",1049 " fill: #D2E3FC;\n",1050 " }\n",1051 "\n",1052 " [theme=dark] .colab-df-convert:hover {\n",1053 " background-color: #434B5C;\n",1054 " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",1055 " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",1056 " fill: #FFFFFF;\n",1057 " }\n",1058 " </style>\n",1059 "\n",1060 " <script>\n",1061 " const buttonEl =\n",1062 " document.querySelector('#df-f4c00acf-abbd-4ebd-b11b-431f15daf928 button.colab-df-convert');\n",1063 " buttonEl.style.display =\n",1064 " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",1065 "\n",1066 " async function convertToInteractive(key) {\n",1067 " const element = document.querySelector('#df-f4c00acf-abbd-4ebd-b11b-431f15daf928');\n",1068 " const dataTable =\n",1069 " await google.colab.kernel.invokeFunction('convertToInteractive',\n",1070 " [key], {});\n",1071 " if (!dataTable) return;\n",1072 "\n",1073 " const docLinkHtml = 'Like what you see? Visit the ' +\n",1074 " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",1075 " + ' to learn more about interactive tables.';\n",1076 " element.innerHTML = '';\n",1077 " dataTable['output_type'] = 'display_data';\n",1078 " await google.colab.output.renderOutput(dataTable, element);\n",1079 " const docLink = document.createElement('div');\n",1080 " docLink.innerHTML = docLinkHtml;\n",1081 " element.appendChild(docLink);\n",1082 " }\n",1083 " </script>\n",1084 " </div>\n",1085 "\n",1086 "\n",1087 " </div>\n",1088 " </div>\n"1089 ],1090 "application/vnd.google.colaboratory.intrinsic+json": {1091 "type": "dataframe",1092 "repr_error": "0"1093 }1094 },1095 "metadata": {}1096 }1097 ],1098 "source": [1099 "def quality_check(df, name=\"DataFrame\"):\n",1100 " print(f\"\\n๐ Quality Check Report for: {name}\")\n",1101 " print(\"=\" * (25 + len(name)))\n",1102 "\n",1103 " # Basic info\n",1104 " print(f\"\\n๐ Shape: {df.shape}\")\n",1105 " print(\"\\n๐ Column Types:\")\n",1106 " print(df.dtypes)\n",1107 "\n",1108 " # Missing values\n",1109 " print(\"\\nโ Missing Values:\")\n",1110 " print(df.isnull().sum())\n",1111 "\n",1112 " # Duplicates\n",1113 " duplicate_count = df.duplicated().sum()\n",1114 " print(f\"\\n๐ Duplicate Rows: {duplicate_count}\")\n",1115 "\n",1116 " # Summary stats\n",1117 " print(\"\\n๐ Summary Statistics:\")\n",1118 " display(df.describe(include='all').transpose())\n",1119 "\n",1120 " # Sample rows\n",1121 " print(\"\\n๐ Sample Rows:\")\n",1122 " display(df.sample(5))\n",1123 "\n",1124 "# Run checks\n",1125 "quality_check(df_reviews, \"df_reviews\")\n",1126 "quality_check(df_sales, \"df_sales\")\n"1127 ]1128 },1129 {1130 "cell_type": "markdown",1131 "metadata": {1132 "id": "TTxUKDYINPxV"1133 },1134 "source": [1135 "## **3.** ๐ญ Perform sentiment analysis using VADER"1136 ]1137 },1138 {1139 "cell_type": "markdown",1140 "metadata": {1141 "id": "OqhYU8rDxQRT"1142 },1143 "source": [1144 "### *a. Initial setup*"1145 ]1146 },1147 {1148 "cell_type": "code",1149 "execution_count": 7,1150 "metadata": {1151 "id": "DNk5w8mNxSZ6"1152 },1153 "outputs": [],1154 "source": [1155 "from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer\n",1156 "\n",1157 "# ๐ค Initialize VADER analyzer\n",1158 "analyzer = SentimentIntensityAnalyzer()"1159 ]1160 },1161 {1162 "cell_type": "markdown",1163 "metadata": {1164 "id": "P123TwSWxVAr"1165 },1166 "source": [1167 "### *b. Create a function get_sentiment_label that will return the label negative, neutral, or positive based on the VADER analyzer's scoring of the text*"1168 ]1169 },1170 {1171 "cell_type": "code",1172 "execution_count": 8,1173 "metadata": {1174 "id": "89809e6f"1175 },1176 "outputs": [],1177 "source": [1178 "def get_sentiment_label(text):\n",1179 " score = analyzer.polarity_scores(text)[\"compound\"]\n",1180 " if score >= 0.05:\n",1181 " return \"positive\"\n",1182 " elif score <= -0.05:\n",1183 " return \"negative\"\n",1184 " else:\n",1185 " return \"neutral\""1186 ]1187 },1188 {1189 "cell_type": "markdown",1190 "metadata": {1191 "id": "DS9eCZ95yQn3"1192 },1193 "source": [1194 "### *c. โ๐ป๐โ๏ธ Apply get_sentiment_label to df_reviews column named review_text to get sentiment_label column*"1195 ]1196 },1197 {1198 "cell_type": "code",1199 "execution_count": 9,1200 "metadata": {