Spaces:
No application file
No application file
Upload 2 files
Browse files- datacreation.ipynb +872 -163
- pythonanalysis.ipynb +0 -0
datacreation.ipynb
CHANGED
|
@@ -26,7 +26,8 @@
|
|
| 26 |
"base_uri": "https://localhost:8080/"
|
| 27 |
},
|
| 28 |
"id": "f48c8f8c",
|
| 29 |
-
"outputId": "
|
|
|
|
| 30 |
},
|
| 31 |
"outputs": [
|
| 32 |
{
|
|
@@ -85,7 +86,7 @@
|
|
| 85 |
},
|
| 86 |
{
|
| 87 |
"cell_type": "code",
|
| 88 |
-
"execution_count":
|
| 89 |
"metadata": {
|
| 90 |
"id": "91d52125"
|
| 91 |
},
|
|
@@ -96,7 +97,7 @@
|
|
| 96 |
"import pandas as pd\n",
|
| 97 |
"import time\n",
|
| 98 |
"\n",
|
| 99 |
-
"base_url = \"
|
| 100 |
"headers = {\"User-Agent\": \"Mozilla/5.0\"}\n",
|
| 101 |
"\n",
|
| 102 |
"titles, prices, ratings = [], [], []"
|
|
@@ -113,7 +114,7 @@
|
|
| 113 |
},
|
| 114 |
{
|
| 115 |
"cell_type": "code",
|
| 116 |
-
"execution_count":
|
| 117 |
"metadata": {
|
| 118 |
"id": "xqO5Y3dnYhxt"
|
| 119 |
},
|
|
@@ -145,12 +146,18 @@
|
|
| 145 |
},
|
| 146 |
{
|
| 147 |
"cell_type": "code",
|
| 148 |
-
"execution_count":
|
| 149 |
"metadata": {
|
| 150 |
"id": "l5FkkNhUYTHh"
|
| 151 |
},
|
| 152 |
"outputs": [],
|
| 153 |
-
"source": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
},
|
| 155 |
{
|
| 156 |
"cell_type": "markdown",
|
|
@@ -163,7 +170,7 @@
|
|
| 163 |
},
|
| 164 |
{
|
| 165 |
"cell_type": "code",
|
| 166 |
-
"execution_count":
|
| 167 |
"metadata": {
|
| 168 |
"id": "lC1U_YHtZifh"
|
| 169 |
},
|
|
@@ -187,14 +194,14 @@
|
|
| 187 |
},
|
| 188 |
{
|
| 189 |
"cell_type": "code",
|
| 190 |
-
"execution_count":
|
| 191 |
"metadata": {
|
| 192 |
"colab": {
|
| 193 |
"base_uri": "https://localhost:8080/",
|
| 194 |
"height": 206
|
| 195 |
},
|
| 196 |
"id": "O_wIvTxYZqCK",
|
| 197 |
-
"outputId": "
|
| 198 |
},
|
| 199 |
"outputs": [
|
| 200 |
{
|
|
@@ -210,7 +217,7 @@
|
|
| 210 |
],
|
| 211 |
"text/html": [
|
| 212 |
"\n",
|
| 213 |
-
" <div id=\"df-
|
| 214 |
" <div>\n",
|
| 215 |
"<style scoped>\n",
|
| 216 |
" .dataframe tbody tr th:only-of-type {\n",
|
|
@@ -271,7 +278,7 @@
|
|
| 271 |
" <div class=\"colab-df-buttons\">\n",
|
| 272 |
"\n",
|
| 273 |
" <div class=\"colab-df-container\">\n",
|
| 274 |
-
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-
|
| 275 |
" title=\"Convert this dataframe to an interactive table.\"\n",
|
| 276 |
" style=\"display:none;\">\n",
|
| 277 |
"\n",
|
|
@@ -323,12 +330,12 @@
|
|
| 323 |
"\n",
|
| 324 |
" <script>\n",
|
| 325 |
" const buttonEl =\n",
|
| 326 |
-
" document.querySelector('#df-
|
| 327 |
" buttonEl.style.display =\n",
|
| 328 |
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
| 329 |
"\n",
|
| 330 |
" async function convertToInteractive(key) {\n",
|
| 331 |
-
" const element = document.querySelector('#df-
|
| 332 |
" const dataTable =\n",
|
| 333 |
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
| 334 |
" [key], {});\n",
|
|
@@ -354,14 +361,16 @@
|
|
| 354 |
"application/vnd.google.colaboratory.intrinsic+json": {
|
| 355 |
"type": "dataframe",
|
| 356 |
"variable_name": "df_books",
|
| 357 |
-
"summary": "{\n \"name\": \"df_books\",\n \"rows\":
|
| 358 |
}
|
| 359 |
},
|
| 360 |
"metadata": {},
|
| 361 |
-
"execution_count":
|
| 362 |
}
|
| 363 |
],
|
| 364 |
-
"source": [
|
|
|
|
|
|
|
| 365 |
},
|
| 366 |
{
|
| 367 |
"cell_type": "markdown",
|
|
@@ -383,7 +392,7 @@
|
|
| 383 |
},
|
| 384 |
{
|
| 385 |
"cell_type": "code",
|
| 386 |
-
"execution_count":
|
| 387 |
"metadata": {
|
| 388 |
"id": "-gPXGcRPuV_9"
|
| 389 |
},
|
|
@@ -410,7 +419,7 @@
|
|
| 410 |
},
|
| 411 |
{
|
| 412 |
"cell_type": "code",
|
| 413 |
-
"execution_count":
|
| 414 |
"metadata": {
|
| 415 |
"id": "mnd5hdAbaNjz"
|
| 416 |
},
|
|
@@ -433,12 +442,191 @@
|
|
| 433 |
},
|
| 434 |
{
|
| 435 |
"cell_type": "code",
|
| 436 |
-
"execution_count":
|
| 437 |
"metadata": {
|
| 438 |
-
"id": "V-G3OCUCgR07"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
},
|
| 440 |
-
"outputs": [
|
| 441 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
},
|
| 443 |
{
|
| 444 |
"cell_type": "markdown",
|
|
@@ -451,7 +639,7 @@
|
|
| 451 |
},
|
| 452 |
{
|
| 453 |
"cell_type": "code",
|
| 454 |
-
"execution_count":
|
| 455 |
"metadata": {
|
| 456 |
"id": "kUtWmr8maZLZ"
|
| 457 |
},
|
|
@@ -477,85 +665,277 @@
|
|
| 477 |
},
|
| 478 |
{
|
| 479 |
"cell_type": "code",
|
| 480 |
-
"execution_count":
|
| 481 |
-
"metadata": {
|
| 482 |
-
"id": "tafQj8_7gYCG"
|
| 483 |
-
},
|
| 484 |
-
"outputs": [],
|
| 485 |
-
"source": []
|
| 486 |
-
},
|
| 487 |
-
{
|
| 488 |
-
"cell_type": "markdown",
|
| 489 |
-
"metadata": {
|
| 490 |
-
"id": "T8AdKkmASq9a"
|
| 491 |
-
},
|
| 492 |
-
"source": [
|
| 493 |
-
"## **4.** 📈 Generate synthetic book sales data of 18 months"
|
| 494 |
-
]
|
| 495 |
-
},
|
| 496 |
-
{
|
| 497 |
-
"cell_type": "markdown",
|
| 498 |
-
"metadata": {
|
| 499 |
-
"id": "OhXbdGD5fH0c"
|
| 500 |
-
},
|
| 501 |
-
"source": [
|
| 502 |
-
"### *a. Create a generate_sales_profit function that would generate sales patterns based on sentiment_label (with some randomness)*"
|
| 503 |
-
]
|
| 504 |
-
},
|
| 505 |
-
{
|
| 506 |
-
"cell_type": "code",
|
| 507 |
-
"execution_count": 12,
|
| 508 |
-
"metadata": {
|
| 509 |
-
"id": "qkVhYPXGbgEn"
|
| 510 |
-
},
|
| 511 |
-
"outputs": [],
|
| 512 |
-
"source": [
|
| 513 |
-
"def generate_sales_profile(sentiment):\n",
|
| 514 |
-
" months = pd.date_range(end=datetime.today(), periods=18, freq=\"M\")\n",
|
| 515 |
-
"\n",
|
| 516 |
-
" if sentiment == \"positive\":\n",
|
| 517 |
-
" base = random.randint(200, 300)\n",
|
| 518 |
-
" trend = np.linspace(base, base + random.randint(20, 60), len(months))\n",
|
| 519 |
-
" elif sentiment == \"negative\":\n",
|
| 520 |
-
" base = random.randint(20, 80)\n",
|
| 521 |
-
" trend = np.linspace(base, base - random.randint(10, 30), len(months))\n",
|
| 522 |
-
" else: # neutral\n",
|
| 523 |
-
" base = random.randint(80, 160)\n",
|
| 524 |
-
" trend = np.full(len(months), base + random.randint(-10, 10))\n",
|
| 525 |
-
"\n",
|
| 526 |
-
" seasonality = 10 * np.sin(np.linspace(0, 3 * np.pi, len(months)))\n",
|
| 527 |
-
" noise = np.random.normal(0, 5, len(months))\n",
|
| 528 |
-
" monthly_sales = np.clip(trend + seasonality + noise, a_min=0, a_max=None).astype(int)\n",
|
| 529 |
-
"\n",
|
| 530 |
-
" return list(zip(months.strftime(\"%Y-%m\"), monthly_sales))"
|
| 531 |
-
]
|
| 532 |
-
},
|
| 533 |
-
{
|
| 534 |
-
"cell_type": "markdown",
|
| 535 |
-
"metadata": {
|
| 536 |
-
"id": "L2ak1HlcgoTe"
|
| 537 |
-
},
|
| 538 |
-
"source": [
|
| 539 |
-
"### *b. Run the function as part of building sales_data*"
|
| 540 |
-
]
|
| 541 |
-
},
|
| 542 |
-
{
|
| 543 |
-
"cell_type": "code",
|
| 544 |
-
"execution_count": 13,
|
| 545 |
"metadata": {
|
| 546 |
-
"id": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 547 |
},
|
| 548 |
-
"outputs": [
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
" })"
|
| 560 |
]
|
| 561 |
},
|
|
@@ -565,18 +945,197 @@
|
|
| 565 |
"id": "4IXZKcCSgxnq"
|
| 566 |
},
|
| 567 |
"source": [
|
| 568 |
-
"### *c. ✋🏻🛑⛔️ Create a df_sales DataFrame from sales_data*"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 569 |
]
|
| 570 |
},
|
| 571 |
-
{
|
| 572 |
-
"cell_type": "code",
|
| 573 |
-
"execution_count": 14,
|
| 574 |
-
"metadata": {
|
| 575 |
-
"id": "wcN6gtiZg-ws"
|
| 576 |
-
},
|
| 577 |
-
"outputs": [],
|
| 578 |
-
"source": []
|
| 579 |
-
},
|
| 580 |
{
|
| 581 |
"cell_type": "markdown",
|
| 582 |
"metadata": {
|
|
@@ -588,13 +1147,13 @@
|
|
| 588 |
},
|
| 589 |
{
|
| 590 |
"cell_type": "code",
|
| 591 |
-
"execution_count":
|
| 592 |
"metadata": {
|
| 593 |
"colab": {
|
| 594 |
"base_uri": "https://localhost:8080/"
|
| 595 |
},
|
| 596 |
"id": "MzbZvLcAhGaH",
|
| 597 |
-
"outputId": "
|
| 598 |
},
|
| 599 |
"outputs": [
|
| 600 |
{
|
|
@@ -602,11 +1161,11 @@
|
|
| 602 |
"name": "stdout",
|
| 603 |
"text": [
|
| 604 |
" title month units_sold sentiment_label\n",
|
| 605 |
-
"0 A Light in the Attic 2024-
|
| 606 |
-
"1 A Light in the Attic 2024-
|
| 607 |
-
"2 A Light in the Attic 2024-
|
| 608 |
-
"3 A Light in the Attic 2024-
|
| 609 |
-
"4 A Light in the Attic
|
| 610 |
]
|
| 611 |
}
|
| 612 |
],
|
|
@@ -636,7 +1195,7 @@
|
|
| 636 |
},
|
| 637 |
{
|
| 638 |
"cell_type": "code",
|
| 639 |
-
"execution_count":
|
| 640 |
"metadata": {
|
| 641 |
"id": "b3cd2a50"
|
| 642 |
},
|
|
@@ -672,7 +1231,7 @@
|
|
| 672 |
},
|
| 673 |
{
|
| 674 |
"cell_type": "code",
|
| 675 |
-
"execution_count":
|
| 676 |
"metadata": {
|
| 677 |
"id": "l2SRc3PjuTGM"
|
| 678 |
},
|
|
@@ -683,7 +1242,8 @@
|
|
| 683 |
" title = row['title']\n",
|
| 684 |
" sentiment_label = row['sentiment_label']\n",
|
| 685 |
" review_pool = synthetic_reviews_by_sentiment[sentiment_label]\n",
|
| 686 |
-
"
|
|
|
|
| 687 |
" for review_text in sampled_reviews:\n",
|
| 688 |
" review_rows.append({\n",
|
| 689 |
" \"title\": title,\n",
|
|
@@ -691,7 +1251,7 @@
|
|
| 691 |
" \"review_text\": review_text,\n",
|
| 692 |
" \"rating\": row['rating'],\n",
|
| 693 |
" \"popularity_score\": row['popularity_score']\n",
|
| 694 |
-
" })"
|
| 695 |
]
|
| 696 |
},
|
| 697 |
{
|
|
@@ -705,7 +1265,7 @@
|
|
| 705 |
},
|
| 706 |
{
|
| 707 |
"cell_type": "code",
|
| 708 |
-
"execution_count":
|
| 709 |
"metadata": {
|
| 710 |
"id": "ZUKUqZsuumsp"
|
| 711 |
},
|
|
@@ -726,13 +1286,13 @@
|
|
| 726 |
},
|
| 727 |
{
|
| 728 |
"cell_type": "code",
|
| 729 |
-
"execution_count":
|
| 730 |
"metadata": {
|
| 731 |
"colab": {
|
| 732 |
"base_uri": "https://localhost:8080/"
|
| 733 |
},
|
| 734 |
"id": "3946e521",
|
| 735 |
-
"outputId": "
|
| 736 |
},
|
| 737 |
"outputs": [
|
| 738 |
{
|
|
@@ -858,36 +1418,202 @@
|
|
| 858 |
},
|
| 859 |
{
|
| 860 |
"cell_type": "code",
|
| 861 |
-
"execution_count":
|
| 862 |
"metadata": {
|
| 863 |
"colab": {
|
| 864 |
-
"base_uri": "https://localhost:8080/"
|
|
|
|
| 865 |
},
|
| 866 |
"id": "xfE8NMqOurKo",
|
| 867 |
-
"outputId": "
|
| 868 |
},
|
| 869 |
"outputs": [
|
| 870 |
{
|
| 871 |
-
"output_type": "
|
| 872 |
-
"
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 888 |
}
|
| 889 |
],
|
| 890 |
-
"source": [
|
|
|
|
|
|
|
| 891 |
}
|
| 892 |
],
|
| 893 |
"metadata": {
|
|
@@ -895,26 +1621,9 @@
|
|
| 895 |
"collapsed_sections": [
|
| 896 |
"jpASMyIQMaAq",
|
| 897 |
"lquNYCbfL9IM",
|
| 898 |
-
"0IWuNpxxYDJF",
|
| 899 |
-
"oCdTsin2Yfp3",
|
| 900 |
-
"T0TOeRC4Yrnn",
|
| 901 |
-
"duI5dv3CZYvF",
|
| 902 |
-
"qMjRKMBQZlJi",
|
| 903 |
"p-1Pr2szaqLk",
|
| 904 |
-
"SIaJUGIpaH4V",
|
| 905 |
-
"pY4yCoIuaQqp",
|
| 906 |
-
"n4-TaNTFgPak",
|
| 907 |
-
"HnngRNTgacYt",
|
| 908 |
-
"HF9F9HIzgT7Z",
|
| 909 |
"T8AdKkmASq9a",
|
| 910 |
-
"
|
| 911 |
-
"L2ak1HlcgoTe",
|
| 912 |
-
"4IXZKcCSgxnq",
|
| 913 |
-
"EhIjz9WohAmZ",
|
| 914 |
-
"Gi4y9M9KuDWx",
|
| 915 |
-
"fQhfVaDmuULT",
|
| 916 |
-
"bmJMXF-Bukdm",
|
| 917 |
-
"RYvGyVfXuo54"
|
| 918 |
],
|
| 919 |
"provenance": []
|
| 920 |
},
|
|
|
|
| 26 |
"base_uri": "https://localhost:8080/"
|
| 27 |
},
|
| 28 |
"id": "f48c8f8c",
|
| 29 |
+
"outputId": "04e1bdd4-2da2-4c3d-9d91-dc5c25a1cf81",
|
| 30 |
+
"collapsed": true
|
| 31 |
},
|
| 32 |
"outputs": [
|
| 33 |
{
|
|
|
|
| 86 |
},
|
| 87 |
{
|
| 88 |
"cell_type": "code",
|
| 89 |
+
"execution_count": 6,
|
| 90 |
"metadata": {
|
| 91 |
"id": "91d52125"
|
| 92 |
},
|
|
|
|
| 97 |
"import pandas as pd\n",
|
| 98 |
"import time\n",
|
| 99 |
"\n",
|
| 100 |
+
"base_url = \"http://books.toscrape.com/catalogue/page-{}.html\"\n",
|
| 101 |
"headers = {\"User-Agent\": \"Mozilla/5.0\"}\n",
|
| 102 |
"\n",
|
| 103 |
"titles, prices, ratings = [], [], []"
|
|
|
|
| 114 |
},
|
| 115 |
{
|
| 116 |
"cell_type": "code",
|
| 117 |
+
"execution_count": 8,
|
| 118 |
"metadata": {
|
| 119 |
"id": "xqO5Y3dnYhxt"
|
| 120 |
},
|
|
|
|
| 146 |
},
|
| 147 |
{
|
| 148 |
"cell_type": "code",
|
| 149 |
+
"execution_count": 10,
|
| 150 |
"metadata": {
|
| 151 |
"id": "l5FkkNhUYTHh"
|
| 152 |
},
|
| 153 |
"outputs": [],
|
| 154 |
+
"source": [
|
| 155 |
+
"df_books = pd.DataFrame({\n",
|
| 156 |
+
" \"title\": titles,\n",
|
| 157 |
+
" \"price\": prices,\n",
|
| 158 |
+
" \"rating\": ratings\n",
|
| 159 |
+
"})"
|
| 160 |
+
]
|
| 161 |
},
|
| 162 |
{
|
| 163 |
"cell_type": "markdown",
|
|
|
|
| 170 |
},
|
| 171 |
{
|
| 172 |
"cell_type": "code",
|
| 173 |
+
"execution_count": 12,
|
| 174 |
"metadata": {
|
| 175 |
"id": "lC1U_YHtZifh"
|
| 176 |
},
|
|
|
|
| 194 |
},
|
| 195 |
{
|
| 196 |
"cell_type": "code",
|
| 197 |
+
"execution_count": 13,
|
| 198 |
"metadata": {
|
| 199 |
"colab": {
|
| 200 |
"base_uri": "https://localhost:8080/",
|
| 201 |
"height": 206
|
| 202 |
},
|
| 203 |
"id": "O_wIvTxYZqCK",
|
| 204 |
+
"outputId": "718c3d95-1dc9-4f67-9940-ebda3ddbf90b"
|
| 205 |
},
|
| 206 |
"outputs": [
|
| 207 |
{
|
|
|
|
| 217 |
],
|
| 218 |
"text/html": [
|
| 219 |
"\n",
|
| 220 |
+
" <div id=\"df-f3614048-0669-4e42-9703-5871bd840543\" class=\"colab-df-container\">\n",
|
| 221 |
" <div>\n",
|
| 222 |
"<style scoped>\n",
|
| 223 |
" .dataframe tbody tr th:only-of-type {\n",
|
|
|
|
| 278 |
" <div class=\"colab-df-buttons\">\n",
|
| 279 |
"\n",
|
| 280 |
" <div class=\"colab-df-container\">\n",
|
| 281 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-f3614048-0669-4e42-9703-5871bd840543')\"\n",
|
| 282 |
" title=\"Convert this dataframe to an interactive table.\"\n",
|
| 283 |
" style=\"display:none;\">\n",
|
| 284 |
"\n",
|
|
|
|
| 330 |
"\n",
|
| 331 |
" <script>\n",
|
| 332 |
" const buttonEl =\n",
|
| 333 |
+
" document.querySelector('#df-f3614048-0669-4e42-9703-5871bd840543 button.colab-df-convert');\n",
|
| 334 |
" buttonEl.style.display =\n",
|
| 335 |
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
| 336 |
"\n",
|
| 337 |
" async function convertToInteractive(key) {\n",
|
| 338 |
+
" const element = document.querySelector('#df-f3614048-0669-4e42-9703-5871bd840543');\n",
|
| 339 |
" const dataTable =\n",
|
| 340 |
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
| 341 |
" [key], {});\n",
|
|
|
|
| 361 |
"application/vnd.google.colaboratory.intrinsic+json": {
|
| 362 |
"type": "dataframe",
|
| 363 |
"variable_name": "df_books",
|
| 364 |
+
"summary": "{\n \"name\": \"df_books\",\n \"rows\": 840,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 799,\n \"samples\": [\n \"Where'd You Go, Bernadette\",\n \"Mockingjay (The Hunger Games #3)\",\n \"The Mindfulness and Acceptance Workbook for Anxiety: A Guide to Breaking Free from Anxiety, Phobias, and Worry Using Acceptance and Commitment Therapy\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"price\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 14.560827565784338,\n \"min\": 10.0,\n \"max\": 59.99,\n \"num_unique_values\": 740,\n \"samples\": [\n 42.95,\n 20.91,\n 21.8\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"One\",\n \"Two\",\n \"Four\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
| 365 |
}
|
| 366 |
},
|
| 367 |
"metadata": {},
|
| 368 |
+
"execution_count": 13
|
| 369 |
}
|
| 370 |
],
|
| 371 |
+
"source": [
|
| 372 |
+
"df_books.head()"
|
| 373 |
+
]
|
| 374 |
},
|
| 375 |
{
|
| 376 |
"cell_type": "markdown",
|
|
|
|
| 392 |
},
|
| 393 |
{
|
| 394 |
"cell_type": "code",
|
| 395 |
+
"execution_count": 14,
|
| 396 |
"metadata": {
|
| 397 |
"id": "-gPXGcRPuV_9"
|
| 398 |
},
|
|
|
|
| 419 |
},
|
| 420 |
{
|
| 421 |
"cell_type": "code",
|
| 422 |
+
"execution_count": 16,
|
| 423 |
"metadata": {
|
| 424 |
"id": "mnd5hdAbaNjz"
|
| 425 |
},
|
|
|
|
| 442 |
},
|
| 443 |
{
|
| 444 |
"cell_type": "code",
|
| 445 |
+
"execution_count": 17,
|
| 446 |
"metadata": {
|
| 447 |
+
"id": "V-G3OCUCgR07",
|
| 448 |
+
"colab": {
|
| 449 |
+
"base_uri": "https://localhost:8080/",
|
| 450 |
+
"height": 206
|
| 451 |
+
},
|
| 452 |
+
"outputId": "034c1831-bbbb-477d-f8fa-a2fcf6f4159c"
|
| 453 |
},
|
| 454 |
+
"outputs": [
|
| 455 |
+
{
|
| 456 |
+
"output_type": "execute_result",
|
| 457 |
+
"data": {
|
| 458 |
+
"text/plain": [
|
| 459 |
+
" title price rating popularity_score\n",
|
| 460 |
+
"0 A Light in the Attic 51.77 Three 3\n",
|
| 461 |
+
"1 Tipping the Velvet 53.74 One 2\n",
|
| 462 |
+
"2 Soumission 50.10 One 2\n",
|
| 463 |
+
"3 Sharp Objects 47.82 Four 4\n",
|
| 464 |
+
"4 Sapiens: A Brief History of Humankind 54.23 Five 3"
|
| 465 |
+
],
|
| 466 |
+
"text/html": [
|
| 467 |
+
"\n",
|
| 468 |
+
" <div id=\"df-749488be-58a0-4a48-abf8-6773255573e7\" class=\"colab-df-container\">\n",
|
| 469 |
+
" <div>\n",
|
| 470 |
+
"<style scoped>\n",
|
| 471 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 472 |
+
" vertical-align: middle;\n",
|
| 473 |
+
" }\n",
|
| 474 |
+
"\n",
|
| 475 |
+
" .dataframe tbody tr th {\n",
|
| 476 |
+
" vertical-align: top;\n",
|
| 477 |
+
" }\n",
|
| 478 |
+
"\n",
|
| 479 |
+
" .dataframe thead th {\n",
|
| 480 |
+
" text-align: right;\n",
|
| 481 |
+
" }\n",
|
| 482 |
+
"</style>\n",
|
| 483 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 484 |
+
" <thead>\n",
|
| 485 |
+
" <tr style=\"text-align: right;\">\n",
|
| 486 |
+
" <th></th>\n",
|
| 487 |
+
" <th>title</th>\n",
|
| 488 |
+
" <th>price</th>\n",
|
| 489 |
+
" <th>rating</th>\n",
|
| 490 |
+
" <th>popularity_score</th>\n",
|
| 491 |
+
" </tr>\n",
|
| 492 |
+
" </thead>\n",
|
| 493 |
+
" <tbody>\n",
|
| 494 |
+
" <tr>\n",
|
| 495 |
+
" <th>0</th>\n",
|
| 496 |
+
" <td>A Light in the Attic</td>\n",
|
| 497 |
+
" <td>51.77</td>\n",
|
| 498 |
+
" <td>Three</td>\n",
|
| 499 |
+
" <td>3</td>\n",
|
| 500 |
+
" </tr>\n",
|
| 501 |
+
" <tr>\n",
|
| 502 |
+
" <th>1</th>\n",
|
| 503 |
+
" <td>Tipping the Velvet</td>\n",
|
| 504 |
+
" <td>53.74</td>\n",
|
| 505 |
+
" <td>One</td>\n",
|
| 506 |
+
" <td>2</td>\n",
|
| 507 |
+
" </tr>\n",
|
| 508 |
+
" <tr>\n",
|
| 509 |
+
" <th>2</th>\n",
|
| 510 |
+
" <td>Soumission</td>\n",
|
| 511 |
+
" <td>50.10</td>\n",
|
| 512 |
+
" <td>One</td>\n",
|
| 513 |
+
" <td>2</td>\n",
|
| 514 |
+
" </tr>\n",
|
| 515 |
+
" <tr>\n",
|
| 516 |
+
" <th>3</th>\n",
|
| 517 |
+
" <td>Sharp Objects</td>\n",
|
| 518 |
+
" <td>47.82</td>\n",
|
| 519 |
+
" <td>Four</td>\n",
|
| 520 |
+
" <td>4</td>\n",
|
| 521 |
+
" </tr>\n",
|
| 522 |
+
" <tr>\n",
|
| 523 |
+
" <th>4</th>\n",
|
| 524 |
+
" <td>Sapiens: A Brief History of Humankind</td>\n",
|
| 525 |
+
" <td>54.23</td>\n",
|
| 526 |
+
" <td>Five</td>\n",
|
| 527 |
+
" <td>3</td>\n",
|
| 528 |
+
" </tr>\n",
|
| 529 |
+
" </tbody>\n",
|
| 530 |
+
"</table>\n",
|
| 531 |
+
"</div>\n",
|
| 532 |
+
" <div class=\"colab-df-buttons\">\n",
|
| 533 |
+
"\n",
|
| 534 |
+
" <div class=\"colab-df-container\">\n",
|
| 535 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-749488be-58a0-4a48-abf8-6773255573e7')\"\n",
|
| 536 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
| 537 |
+
" style=\"display:none;\">\n",
|
| 538 |
+
"\n",
|
| 539 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
| 540 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
| 541 |
+
" </svg>\n",
|
| 542 |
+
" </button>\n",
|
| 543 |
+
"\n",
|
| 544 |
+
" <style>\n",
|
| 545 |
+
" .colab-df-container {\n",
|
| 546 |
+
" display:flex;\n",
|
| 547 |
+
" gap: 12px;\n",
|
| 548 |
+
" }\n",
|
| 549 |
+
"\n",
|
| 550 |
+
" .colab-df-convert {\n",
|
| 551 |
+
" background-color: #E8F0FE;\n",
|
| 552 |
+
" border: none;\n",
|
| 553 |
+
" border-radius: 50%;\n",
|
| 554 |
+
" cursor: pointer;\n",
|
| 555 |
+
" display: none;\n",
|
| 556 |
+
" fill: #1967D2;\n",
|
| 557 |
+
" height: 32px;\n",
|
| 558 |
+
" padding: 0 0 0 0;\n",
|
| 559 |
+
" width: 32px;\n",
|
| 560 |
+
" }\n",
|
| 561 |
+
"\n",
|
| 562 |
+
" .colab-df-convert:hover {\n",
|
| 563 |
+
" background-color: #E2EBFA;\n",
|
| 564 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
| 565 |
+
" fill: #174EA6;\n",
|
| 566 |
+
" }\n",
|
| 567 |
+
"\n",
|
| 568 |
+
" .colab-df-buttons div {\n",
|
| 569 |
+
" margin-bottom: 4px;\n",
|
| 570 |
+
" }\n",
|
| 571 |
+
"\n",
|
| 572 |
+
" [theme=dark] .colab-df-convert {\n",
|
| 573 |
+
" background-color: #3B4455;\n",
|
| 574 |
+
" fill: #D2E3FC;\n",
|
| 575 |
+
" }\n",
|
| 576 |
+
"\n",
|
| 577 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
| 578 |
+
" background-color: #434B5C;\n",
|
| 579 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
| 580 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
| 581 |
+
" fill: #FFFFFF;\n",
|
| 582 |
+
" }\n",
|
| 583 |
+
" </style>\n",
|
| 584 |
+
"\n",
|
| 585 |
+
" <script>\n",
|
| 586 |
+
" const buttonEl =\n",
|
| 587 |
+
" document.querySelector('#df-749488be-58a0-4a48-abf8-6773255573e7 button.colab-df-convert');\n",
|
| 588 |
+
" buttonEl.style.display =\n",
|
| 589 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
| 590 |
+
"\n",
|
| 591 |
+
" async function convertToInteractive(key) {\n",
|
| 592 |
+
" const element = document.querySelector('#df-749488be-58a0-4a48-abf8-6773255573e7');\n",
|
| 593 |
+
" const dataTable =\n",
|
| 594 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
| 595 |
+
" [key], {});\n",
|
| 596 |
+
" if (!dataTable) return;\n",
|
| 597 |
+
"\n",
|
| 598 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
| 599 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
| 600 |
+
" + ' to learn more about interactive tables.';\n",
|
| 601 |
+
" element.innerHTML = '';\n",
|
| 602 |
+
" dataTable['output_type'] = 'display_data';\n",
|
| 603 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
| 604 |
+
" const docLink = document.createElement('div');\n",
|
| 605 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
| 606 |
+
" element.appendChild(docLink);\n",
|
| 607 |
+
" }\n",
|
| 608 |
+
" </script>\n",
|
| 609 |
+
" </div>\n",
|
| 610 |
+
"\n",
|
| 611 |
+
"\n",
|
| 612 |
+
" </div>\n",
|
| 613 |
+
" </div>\n"
|
| 614 |
+
],
|
| 615 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
| 616 |
+
"type": "dataframe",
|
| 617 |
+
"variable_name": "df_books",
|
| 618 |
+
"summary": "{\n \"name\": \"df_books\",\n \"rows\": 840,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 799,\n \"samples\": [\n \"Where'd You Go, Bernadette\",\n \"Mockingjay (The Hunger Games #3)\",\n \"The Mindfulness and Acceptance Workbook for Anxiety: A Guide to Breaking Free from Anxiety, Phobias, and Worry Using Acceptance and Commitment Therapy\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"price\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 14.560827565784338,\n \"min\": 10.0,\n \"max\": 59.99,\n \"num_unique_values\": 740,\n \"samples\": [\n 42.95,\n 20.91,\n 21.8\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"One\",\n \"Two\",\n \"Four\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"popularity_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1,\n \"max\": 5,\n \"num_unique_values\": 5,\n \"samples\": [\n 2,\n 5,\n 4\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
| 619 |
+
}
|
| 620 |
+
},
|
| 621 |
+
"metadata": {},
|
| 622 |
+
"execution_count": 17
|
| 623 |
+
}
|
| 624 |
+
],
|
| 625 |
+
"source": [
|
| 626 |
+
"df_books[\"popularity_score\"] = df_books[\"rating\"].apply(generate_popularity_score)\n",
|
| 627 |
+
"\n",
|
| 628 |
+
"df_books.head()"
|
| 629 |
+
]
|
| 630 |
},
|
| 631 |
{
|
| 632 |
"cell_type": "markdown",
|
|
|
|
| 639 |
},
|
| 640 |
{
|
| 641 |
"cell_type": "code",
|
| 642 |
+
"execution_count": 18,
|
| 643 |
"metadata": {
|
| 644 |
"id": "kUtWmr8maZLZ"
|
| 645 |
},
|
|
|
|
| 665 |
},
|
| 666 |
{
|
| 667 |
"cell_type": "code",
|
| 668 |
+
"execution_count": 19,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 669 |
"metadata": {
|
| 670 |
+
"id": "tafQj8_7gYCG",
|
| 671 |
+
"colab": {
|
| 672 |
+
"base_uri": "https://localhost:8080/",
|
| 673 |
+
"height": 206
|
| 674 |
+
},
|
| 675 |
+
"outputId": "dbb4cead-9675-4491-db0e-0fedb34a10b9"
|
| 676 |
},
|
| 677 |
+
"outputs": [
|
| 678 |
+
{
|
| 679 |
+
"output_type": "execute_result",
|
| 680 |
+
"data": {
|
| 681 |
+
"text/plain": [
|
| 682 |
+
" title price rating popularity_score \\\n",
|
| 683 |
+
"0 A Light in the Attic 51.77 Three 3 \n",
|
| 684 |
+
"1 Tipping the Velvet 53.74 One 2 \n",
|
| 685 |
+
"2 Soumission 50.10 One 2 \n",
|
| 686 |
+
"3 Sharp Objects 47.82 Four 4 \n",
|
| 687 |
+
"4 Sapiens: A Brief History of Humankind 54.23 Five 3 \n",
|
| 688 |
+
"\n",
|
| 689 |
+
" sentiment_label \n",
|
| 690 |
+
"0 neutral \n",
|
| 691 |
+
"1 negative \n",
|
| 692 |
+
"2 negative \n",
|
| 693 |
+
"3 positive \n",
|
| 694 |
+
"4 neutral "
|
| 695 |
+
],
|
| 696 |
+
"text/html": [
|
| 697 |
+
"\n",
|
| 698 |
+
" <div id=\"df-4de4fca6-e8b0-45a4-aeb2-25e946439896\" class=\"colab-df-container\">\n",
|
| 699 |
+
" <div>\n",
|
| 700 |
+
"<style scoped>\n",
|
| 701 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 702 |
+
" vertical-align: middle;\n",
|
| 703 |
+
" }\n",
|
| 704 |
+
"\n",
|
| 705 |
+
" .dataframe tbody tr th {\n",
|
| 706 |
+
" vertical-align: top;\n",
|
| 707 |
+
" }\n",
|
| 708 |
+
"\n",
|
| 709 |
+
" .dataframe thead th {\n",
|
| 710 |
+
" text-align: right;\n",
|
| 711 |
+
" }\n",
|
| 712 |
+
"</style>\n",
|
| 713 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 714 |
+
" <thead>\n",
|
| 715 |
+
" <tr style=\"text-align: right;\">\n",
|
| 716 |
+
" <th></th>\n",
|
| 717 |
+
" <th>title</th>\n",
|
| 718 |
+
" <th>price</th>\n",
|
| 719 |
+
" <th>rating</th>\n",
|
| 720 |
+
" <th>popularity_score</th>\n",
|
| 721 |
+
" <th>sentiment_label</th>\n",
|
| 722 |
+
" </tr>\n",
|
| 723 |
+
" </thead>\n",
|
| 724 |
+
" <tbody>\n",
|
| 725 |
+
" <tr>\n",
|
| 726 |
+
" <th>0</th>\n",
|
| 727 |
+
" <td>A Light in the Attic</td>\n",
|
| 728 |
+
" <td>51.77</td>\n",
|
| 729 |
+
" <td>Three</td>\n",
|
| 730 |
+
" <td>3</td>\n",
|
| 731 |
+
" <td>neutral</td>\n",
|
| 732 |
+
" </tr>\n",
|
| 733 |
+
" <tr>\n",
|
| 734 |
+
" <th>1</th>\n",
|
| 735 |
+
" <td>Tipping the Velvet</td>\n",
|
| 736 |
+
" <td>53.74</td>\n",
|
| 737 |
+
" <td>One</td>\n",
|
| 738 |
+
" <td>2</td>\n",
|
| 739 |
+
" <td>negative</td>\n",
|
| 740 |
+
" </tr>\n",
|
| 741 |
+
" <tr>\n",
|
| 742 |
+
" <th>2</th>\n",
|
| 743 |
+
" <td>Soumission</td>\n",
|
| 744 |
+
" <td>50.10</td>\n",
|
| 745 |
+
" <td>One</td>\n",
|
| 746 |
+
" <td>2</td>\n",
|
| 747 |
+
" <td>negative</td>\n",
|
| 748 |
+
" </tr>\n",
|
| 749 |
+
" <tr>\n",
|
| 750 |
+
" <th>3</th>\n",
|
| 751 |
+
" <td>Sharp Objects</td>\n",
|
| 752 |
+
" <td>47.82</td>\n",
|
| 753 |
+
" <td>Four</td>\n",
|
| 754 |
+
" <td>4</td>\n",
|
| 755 |
+
" <td>positive</td>\n",
|
| 756 |
+
" </tr>\n",
|
| 757 |
+
" <tr>\n",
|
| 758 |
+
" <th>4</th>\n",
|
| 759 |
+
" <td>Sapiens: A Brief History of Humankind</td>\n",
|
| 760 |
+
" <td>54.23</td>\n",
|
| 761 |
+
" <td>Five</td>\n",
|
| 762 |
+
" <td>3</td>\n",
|
| 763 |
+
" <td>neutral</td>\n",
|
| 764 |
+
" </tr>\n",
|
| 765 |
+
" </tbody>\n",
|
| 766 |
+
"</table>\n",
|
| 767 |
+
"</div>\n",
|
| 768 |
+
" <div class=\"colab-df-buttons\">\n",
|
| 769 |
+
"\n",
|
| 770 |
+
" <div class=\"colab-df-container\">\n",
|
| 771 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-4de4fca6-e8b0-45a4-aeb2-25e946439896')\"\n",
|
| 772 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
| 773 |
+
" style=\"display:none;\">\n",
|
| 774 |
+
"\n",
|
| 775 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
| 776 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
| 777 |
+
" </svg>\n",
|
| 778 |
+
" </button>\n",
|
| 779 |
+
"\n",
|
| 780 |
+
" <style>\n",
|
| 781 |
+
" .colab-df-container {\n",
|
| 782 |
+
" display:flex;\n",
|
| 783 |
+
" gap: 12px;\n",
|
| 784 |
+
" }\n",
|
| 785 |
+
"\n",
|
| 786 |
+
" .colab-df-convert {\n",
|
| 787 |
+
" background-color: #E8F0FE;\n",
|
| 788 |
+
" border: none;\n",
|
| 789 |
+
" border-radius: 50%;\n",
|
| 790 |
+
" cursor: pointer;\n",
|
| 791 |
+
" display: none;\n",
|
| 792 |
+
" fill: #1967D2;\n",
|
| 793 |
+
" height: 32px;\n",
|
| 794 |
+
" padding: 0 0 0 0;\n",
|
| 795 |
+
" width: 32px;\n",
|
| 796 |
+
" }\n",
|
| 797 |
+
"\n",
|
| 798 |
+
" .colab-df-convert:hover {\n",
|
| 799 |
+
" background-color: #E2EBFA;\n",
|
| 800 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
| 801 |
+
" fill: #174EA6;\n",
|
| 802 |
+
" }\n",
|
| 803 |
+
"\n",
|
| 804 |
+
" .colab-df-buttons div {\n",
|
| 805 |
+
" margin-bottom: 4px;\n",
|
| 806 |
+
" }\n",
|
| 807 |
+
"\n",
|
| 808 |
+
" [theme=dark] .colab-df-convert {\n",
|
| 809 |
+
" background-color: #3B4455;\n",
|
| 810 |
+
" fill: #D2E3FC;\n",
|
| 811 |
+
" }\n",
|
| 812 |
+
"\n",
|
| 813 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
| 814 |
+
" background-color: #434B5C;\n",
|
| 815 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
| 816 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
| 817 |
+
" fill: #FFFFFF;\n",
|
| 818 |
+
" }\n",
|
| 819 |
+
" </style>\n",
|
| 820 |
+
"\n",
|
| 821 |
+
" <script>\n",
|
| 822 |
+
" const buttonEl =\n",
|
| 823 |
+
" document.querySelector('#df-4de4fca6-e8b0-45a4-aeb2-25e946439896 button.colab-df-convert');\n",
|
| 824 |
+
" buttonEl.style.display =\n",
|
| 825 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
| 826 |
+
"\n",
|
| 827 |
+
" async function convertToInteractive(key) {\n",
|
| 828 |
+
" const element = document.querySelector('#df-4de4fca6-e8b0-45a4-aeb2-25e946439896');\n",
|
| 829 |
+
" const dataTable =\n",
|
| 830 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
| 831 |
+
" [key], {});\n",
|
| 832 |
+
" if (!dataTable) return;\n",
|
| 833 |
+
"\n",
|
| 834 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
| 835 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
| 836 |
+
" + ' to learn more about interactive tables.';\n",
|
| 837 |
+
" element.innerHTML = '';\n",
|
| 838 |
+
" dataTable['output_type'] = 'display_data';\n",
|
| 839 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
| 840 |
+
" const docLink = document.createElement('div');\n",
|
| 841 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
| 842 |
+
" element.appendChild(docLink);\n",
|
| 843 |
+
" }\n",
|
| 844 |
+
" </script>\n",
|
| 845 |
+
" </div>\n",
|
| 846 |
+
"\n",
|
| 847 |
+
"\n",
|
| 848 |
+
" </div>\n",
|
| 849 |
+
" </div>\n"
|
| 850 |
+
],
|
| 851 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
| 852 |
+
"type": "dataframe",
|
| 853 |
+
"variable_name": "df_books",
|
| 854 |
+
"summary": "{\n \"name\": \"df_books\",\n \"rows\": 840,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 799,\n \"samples\": [\n \"Where'd You Go, Bernadette\",\n \"Mockingjay (The Hunger Games #3)\",\n \"The Mindfulness and Acceptance Workbook for Anxiety: A Guide to Breaking Free from Anxiety, Phobias, and Worry Using Acceptance and Commitment Therapy\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"price\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 14.560827565784338,\n \"min\": 10.0,\n \"max\": 59.99,\n \"num_unique_values\": 740,\n \"samples\": [\n 42.95,\n 20.91,\n 21.8\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"One\",\n \"Two\",\n \"Four\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"popularity_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1,\n \"max\": 5,\n \"num_unique_values\": 5,\n \"samples\": [\n 2,\n 5,\n 4\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"sentiment_label\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"neutral\",\n \"negative\",\n \"positive\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
| 855 |
+
}
|
| 856 |
+
},
|
| 857 |
+
"metadata": {},
|
| 858 |
+
"execution_count": 19
|
| 859 |
+
}
|
| 860 |
+
],
|
| 861 |
+
"source": [
|
| 862 |
+
"df_books[\"sentiment_label\"] = df_books[\"popularity_score\"].apply(get_sentiment)\n",
|
| 863 |
+
"\n",
|
| 864 |
+
"df_books.head()"
|
| 865 |
+
]
|
| 866 |
+
},
|
| 867 |
+
{
|
| 868 |
+
"cell_type": "markdown",
|
| 869 |
+
"metadata": {
|
| 870 |
+
"id": "T8AdKkmASq9a"
|
| 871 |
+
},
|
| 872 |
+
"source": [
|
| 873 |
+
"## **4.** 📈 Generate synthetic book sales data of 18 months"
|
| 874 |
+
]
|
| 875 |
+
},
|
| 876 |
+
{
|
| 877 |
+
"cell_type": "markdown",
|
| 878 |
+
"metadata": {
|
| 879 |
+
"id": "OhXbdGD5fH0c"
|
| 880 |
+
},
|
| 881 |
+
"source": [
|
| 882 |
+
"### *a. Create a generate_sales_profit function that would generate sales patterns based on sentiment_label (with some randomness)*"
|
| 883 |
+
]
|
| 884 |
+
},
|
| 885 |
+
{
|
| 886 |
+
"cell_type": "code",
|
| 887 |
+
"execution_count": 20,
|
| 888 |
+
"metadata": {
|
| 889 |
+
"id": "qkVhYPXGbgEn"
|
| 890 |
+
},
|
| 891 |
+
"outputs": [],
|
| 892 |
+
"source": [
|
| 893 |
+
"def generate_sales_profile(sentiment):\n",
|
| 894 |
+
" months = pd.date_range(end=datetime.today(), periods=18, freq=\"M\")\n",
|
| 895 |
+
"\n",
|
| 896 |
+
" if sentiment == \"positive\":\n",
|
| 897 |
+
" base = random.randint(200, 300)\n",
|
| 898 |
+
" trend = np.linspace(base, base + random.randint(20, 60), len(months))\n",
|
| 899 |
+
" elif sentiment == \"negative\":\n",
|
| 900 |
+
" base = random.randint(20, 80)\n",
|
| 901 |
+
" trend = np.linspace(base, base - random.randint(10, 30), len(months))\n",
|
| 902 |
+
" else: # neutral\n",
|
| 903 |
+
" base = random.randint(80, 160)\n",
|
| 904 |
+
" trend = np.full(len(months), base + random.randint(-10, 10))\n",
|
| 905 |
+
"\n",
|
| 906 |
+
" seasonality = 10 * np.sin(np.linspace(0, 3 * np.pi, len(months)))\n",
|
| 907 |
+
" noise = np.random.normal(0, 5, len(months))\n",
|
| 908 |
+
" monthly_sales = np.clip(trend + seasonality + noise, a_min=0, a_max=None).astype(int)\n",
|
| 909 |
+
"\n",
|
| 910 |
+
" return list(zip(months.strftime(\"%Y-%m\"), monthly_sales))"
|
| 911 |
+
]
|
| 912 |
+
},
|
| 913 |
+
{
|
| 914 |
+
"cell_type": "markdown",
|
| 915 |
+
"metadata": {
|
| 916 |
+
"id": "L2ak1HlcgoTe"
|
| 917 |
+
},
|
| 918 |
+
"source": [
|
| 919 |
+
"### *b. Run the function as part of building sales_data*"
|
| 920 |
+
]
|
| 921 |
+
},
|
| 922 |
+
{
|
| 923 |
+
"cell_type": "code",
|
| 924 |
+
"execution_count": 21,
|
| 925 |
+
"metadata": {
|
| 926 |
+
"id": "SlJ24AUafoDB"
|
| 927 |
+
},
|
| 928 |
+
"outputs": [],
|
| 929 |
+
"source": [
|
| 930 |
+
"sales_data = []\n",
|
| 931 |
+
"for _, row in df_books.iterrows():\n",
|
| 932 |
+
" records = generate_sales_profile(row[\"sentiment_label\"])\n",
|
| 933 |
+
" for month, units in records:\n",
|
| 934 |
+
" sales_data.append({\n",
|
| 935 |
+
" \"title\": row[\"title\"],\n",
|
| 936 |
+
" \"month\": month,\n",
|
| 937 |
+
" \"units_sold\": units,\n",
|
| 938 |
+
" \"sentiment_label\": row[\"sentiment_label\"]\n",
|
| 939 |
" })"
|
| 940 |
]
|
| 941 |
},
|
|
|
|
| 945 |
"id": "4IXZKcCSgxnq"
|
| 946 |
},
|
| 947 |
"source": [
|
| 948 |
+
"### *c. ✋🏻🛑⛔️ Create a df_sales DataFrame from sales_data*"
|
| 949 |
+
]
|
| 950 |
+
},
|
| 951 |
+
{
|
| 952 |
+
"cell_type": "code",
|
| 953 |
+
"execution_count": 22,
|
| 954 |
+
"metadata": {
|
| 955 |
+
"id": "wcN6gtiZg-ws",
|
| 956 |
+
"colab": {
|
| 957 |
+
"base_uri": "https://localhost:8080/",
|
| 958 |
+
"height": 206
|
| 959 |
+
},
|
| 960 |
+
"outputId": "80a1cc44-a7d5-42c8-ae24-5e0536fea67c"
|
| 961 |
+
},
|
| 962 |
+
"outputs": [
|
| 963 |
+
{
|
| 964 |
+
"output_type": "execute_result",
|
| 965 |
+
"data": {
|
| 966 |
+
"text/plain": [
|
| 967 |
+
" title month units_sold sentiment_label\n",
|
| 968 |
+
"0 A Light in the Attic 2024-09 127 neutral\n",
|
| 969 |
+
"1 A Light in the Attic 2024-10 136 neutral\n",
|
| 970 |
+
"2 A Light in the Attic 2024-11 129 neutral\n",
|
| 971 |
+
"3 A Light in the Attic 2024-12 134 neutral\n",
|
| 972 |
+
"4 A Light in the Attic 2025-01 135 neutral"
|
| 973 |
+
],
|
| 974 |
+
"text/html": [
|
| 975 |
+
"\n",
|
| 976 |
+
" <div id=\"df-a851ff68-be2f-4e9a-849f-62e1c2a663f1\" class=\"colab-df-container\">\n",
|
| 977 |
+
" <div>\n",
|
| 978 |
+
"<style scoped>\n",
|
| 979 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 980 |
+
" vertical-align: middle;\n",
|
| 981 |
+
" }\n",
|
| 982 |
+
"\n",
|
| 983 |
+
" .dataframe tbody tr th {\n",
|
| 984 |
+
" vertical-align: top;\n",
|
| 985 |
+
" }\n",
|
| 986 |
+
"\n",
|
| 987 |
+
" .dataframe thead th {\n",
|
| 988 |
+
" text-align: right;\n",
|
| 989 |
+
" }\n",
|
| 990 |
+
"</style>\n",
|
| 991 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 992 |
+
" <thead>\n",
|
| 993 |
+
" <tr style=\"text-align: right;\">\n",
|
| 994 |
+
" <th></th>\n",
|
| 995 |
+
" <th>title</th>\n",
|
| 996 |
+
" <th>month</th>\n",
|
| 997 |
+
" <th>units_sold</th>\n",
|
| 998 |
+
" <th>sentiment_label</th>\n",
|
| 999 |
+
" </tr>\n",
|
| 1000 |
+
" </thead>\n",
|
| 1001 |
+
" <tbody>\n",
|
| 1002 |
+
" <tr>\n",
|
| 1003 |
+
" <th>0</th>\n",
|
| 1004 |
+
" <td>A Light in the Attic</td>\n",
|
| 1005 |
+
" <td>2024-09</td>\n",
|
| 1006 |
+
" <td>127</td>\n",
|
| 1007 |
+
" <td>neutral</td>\n",
|
| 1008 |
+
" </tr>\n",
|
| 1009 |
+
" <tr>\n",
|
| 1010 |
+
" <th>1</th>\n",
|
| 1011 |
+
" <td>A Light in the Attic</td>\n",
|
| 1012 |
+
" <td>2024-10</td>\n",
|
| 1013 |
+
" <td>136</td>\n",
|
| 1014 |
+
" <td>neutral</td>\n",
|
| 1015 |
+
" </tr>\n",
|
| 1016 |
+
" <tr>\n",
|
| 1017 |
+
" <th>2</th>\n",
|
| 1018 |
+
" <td>A Light in the Attic</td>\n",
|
| 1019 |
+
" <td>2024-11</td>\n",
|
| 1020 |
+
" <td>129</td>\n",
|
| 1021 |
+
" <td>neutral</td>\n",
|
| 1022 |
+
" </tr>\n",
|
| 1023 |
+
" <tr>\n",
|
| 1024 |
+
" <th>3</th>\n",
|
| 1025 |
+
" <td>A Light in the Attic</td>\n",
|
| 1026 |
+
" <td>2024-12</td>\n",
|
| 1027 |
+
" <td>134</td>\n",
|
| 1028 |
+
" <td>neutral</td>\n",
|
| 1029 |
+
" </tr>\n",
|
| 1030 |
+
" <tr>\n",
|
| 1031 |
+
" <th>4</th>\n",
|
| 1032 |
+
" <td>A Light in the Attic</td>\n",
|
| 1033 |
+
" <td>2025-01</td>\n",
|
| 1034 |
+
" <td>135</td>\n",
|
| 1035 |
+
" <td>neutral</td>\n",
|
| 1036 |
+
" </tr>\n",
|
| 1037 |
+
" </tbody>\n",
|
| 1038 |
+
"</table>\n",
|
| 1039 |
+
"</div>\n",
|
| 1040 |
+
" <div class=\"colab-df-buttons\">\n",
|
| 1041 |
+
"\n",
|
| 1042 |
+
" <div class=\"colab-df-container\">\n",
|
| 1043 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a851ff68-be2f-4e9a-849f-62e1c2a663f1')\"\n",
|
| 1044 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
| 1045 |
+
" style=\"display:none;\">\n",
|
| 1046 |
+
"\n",
|
| 1047 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
| 1048 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
| 1049 |
+
" </svg>\n",
|
| 1050 |
+
" </button>\n",
|
| 1051 |
+
"\n",
|
| 1052 |
+
" <style>\n",
|
| 1053 |
+
" .colab-df-container {\n",
|
| 1054 |
+
" display:flex;\n",
|
| 1055 |
+
" gap: 12px;\n",
|
| 1056 |
+
" }\n",
|
| 1057 |
+
"\n",
|
| 1058 |
+
" .colab-df-convert {\n",
|
| 1059 |
+
" background-color: #E8F0FE;\n",
|
| 1060 |
+
" border: none;\n",
|
| 1061 |
+
" border-radius: 50%;\n",
|
| 1062 |
+
" cursor: pointer;\n",
|
| 1063 |
+
" display: none;\n",
|
| 1064 |
+
" fill: #1967D2;\n",
|
| 1065 |
+
" height: 32px;\n",
|
| 1066 |
+
" padding: 0 0 0 0;\n",
|
| 1067 |
+
" width: 32px;\n",
|
| 1068 |
+
" }\n",
|
| 1069 |
+
"\n",
|
| 1070 |
+
" .colab-df-convert:hover {\n",
|
| 1071 |
+
" background-color: #E2EBFA;\n",
|
| 1072 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
| 1073 |
+
" fill: #174EA6;\n",
|
| 1074 |
+
" }\n",
|
| 1075 |
+
"\n",
|
| 1076 |
+
" .colab-df-buttons div {\n",
|
| 1077 |
+
" margin-bottom: 4px;\n",
|
| 1078 |
+
" }\n",
|
| 1079 |
+
"\n",
|
| 1080 |
+
" [theme=dark] .colab-df-convert {\n",
|
| 1081 |
+
" background-color: #3B4455;\n",
|
| 1082 |
+
" fill: #D2E3FC;\n",
|
| 1083 |
+
" }\n",
|
| 1084 |
+
"\n",
|
| 1085 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
| 1086 |
+
" background-color: #434B5C;\n",
|
| 1087 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
| 1088 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
| 1089 |
+
" fill: #FFFFFF;\n",
|
| 1090 |
+
" }\n",
|
| 1091 |
+
" </style>\n",
|
| 1092 |
+
"\n",
|
| 1093 |
+
" <script>\n",
|
| 1094 |
+
" const buttonEl =\n",
|
| 1095 |
+
" document.querySelector('#df-a851ff68-be2f-4e9a-849f-62e1c2a663f1 button.colab-df-convert');\n",
|
| 1096 |
+
" buttonEl.style.display =\n",
|
| 1097 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
| 1098 |
+
"\n",
|
| 1099 |
+
" async function convertToInteractive(key) {\n",
|
| 1100 |
+
" const element = document.querySelector('#df-a851ff68-be2f-4e9a-849f-62e1c2a663f1');\n",
|
| 1101 |
+
" const dataTable =\n",
|
| 1102 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
| 1103 |
+
" [key], {});\n",
|
| 1104 |
+
" if (!dataTable) return;\n",
|
| 1105 |
+
"\n",
|
| 1106 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
| 1107 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
| 1108 |
+
" + ' to learn more about interactive tables.';\n",
|
| 1109 |
+
" element.innerHTML = '';\n",
|
| 1110 |
+
" dataTable['output_type'] = 'display_data';\n",
|
| 1111 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
| 1112 |
+
" const docLink = document.createElement('div');\n",
|
| 1113 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
| 1114 |
+
" element.appendChild(docLink);\n",
|
| 1115 |
+
" }\n",
|
| 1116 |
+
" </script>\n",
|
| 1117 |
+
" </div>\n",
|
| 1118 |
+
"\n",
|
| 1119 |
+
"\n",
|
| 1120 |
+
" </div>\n",
|
| 1121 |
+
" </div>\n"
|
| 1122 |
+
],
|
| 1123 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
| 1124 |
+
"type": "dataframe",
|
| 1125 |
+
"variable_name": "df_sales",
|
| 1126 |
+
"summary": "{\n \"name\": \"df_sales\",\n \"rows\": 15120,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 799,\n \"samples\": [\n \"Where'd You Go, Bernadette\",\n \"Mockingjay (The Hunger Games #3)\",\n \"The Mindfulness and Acceptance Workbook for Anxiety: A Guide to Breaking Free from Anxiety, Phobias, and Worry Using Acceptance and Commitment Therapy\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"month\",\n \"properties\": {\n \"dtype\": \"object\",\n \"num_unique_values\": 18,\n \"samples\": [\n \"2024-09\",\n \"2024-10\",\n \"2025-05\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"units_sold\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 98,\n \"min\": 0,\n \"max\": 362,\n \"num_unique_values\": 355,\n \"samples\": [\n 247,\n 302,\n 56\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"sentiment_label\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"neutral\",\n \"negative\",\n \"positive\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
| 1127 |
+
}
|
| 1128 |
+
},
|
| 1129 |
+
"metadata": {},
|
| 1130 |
+
"execution_count": 22
|
| 1131 |
+
}
|
| 1132 |
+
],
|
| 1133 |
+
"source": [
|
| 1134 |
+
"df_sales = pd.DataFrame(sales_data)\n",
|
| 1135 |
+
"\n",
|
| 1136 |
+
"df_sales.head()"
|
| 1137 |
]
|
| 1138 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1139 |
{
|
| 1140 |
"cell_type": "markdown",
|
| 1141 |
"metadata": {
|
|
|
|
| 1147 |
},
|
| 1148 |
{
|
| 1149 |
"cell_type": "code",
|
| 1150 |
+
"execution_count": 23,
|
| 1151 |
"metadata": {
|
| 1152 |
"colab": {
|
| 1153 |
"base_uri": "https://localhost:8080/"
|
| 1154 |
},
|
| 1155 |
"id": "MzbZvLcAhGaH",
|
| 1156 |
+
"outputId": "385401c5-fa65-4eae-fff5-e8ecbcc99fc4"
|
| 1157 |
},
|
| 1158 |
"outputs": [
|
| 1159 |
{
|
|
|
|
| 1161 |
"name": "stdout",
|
| 1162 |
"text": [
|
| 1163 |
" title month units_sold sentiment_label\n",
|
| 1164 |
+
"0 A Light in the Attic 2024-09 127 neutral\n",
|
| 1165 |
+
"1 A Light in the Attic 2024-10 136 neutral\n",
|
| 1166 |
+
"2 A Light in the Attic 2024-11 129 neutral\n",
|
| 1167 |
+
"3 A Light in the Attic 2024-12 134 neutral\n",
|
| 1168 |
+
"4 A Light in the Attic 2025-01 135 neutral\n"
|
| 1169 |
]
|
| 1170 |
}
|
| 1171 |
],
|
|
|
|
| 1195 |
},
|
| 1196 |
{
|
| 1197 |
"cell_type": "code",
|
| 1198 |
+
"execution_count": 24,
|
| 1199 |
"metadata": {
|
| 1200 |
"id": "b3cd2a50"
|
| 1201 |
},
|
|
|
|
| 1231 |
},
|
| 1232 |
{
|
| 1233 |
"cell_type": "code",
|
| 1234 |
+
"execution_count": 27,
|
| 1235 |
"metadata": {
|
| 1236 |
"id": "l2SRc3PjuTGM"
|
| 1237 |
},
|
|
|
|
| 1242 |
" title = row['title']\n",
|
| 1243 |
" sentiment_label = row['sentiment_label']\n",
|
| 1244 |
" review_pool = synthetic_reviews_by_sentiment[sentiment_label]\n",
|
| 1245 |
+
" # Sample at most the number of available reviews to avoid ValueError\n",
|
| 1246 |
+
" sampled_reviews = random.sample(review_pool, min(10, len(review_pool)))\n",
|
| 1247 |
" for review_text in sampled_reviews:\n",
|
| 1248 |
" review_rows.append({\n",
|
| 1249 |
" \"title\": title,\n",
|
|
|
|
| 1251 |
" \"review_text\": review_text,\n",
|
| 1252 |
" \"rating\": row['rating'],\n",
|
| 1253 |
" \"popularity_score\": row['popularity_score']\n",
|
| 1254 |
+
" })\n"
|
| 1255 |
]
|
| 1256 |
},
|
| 1257 |
{
|
|
|
|
| 1265 |
},
|
| 1266 |
{
|
| 1267 |
"cell_type": "code",
|
| 1268 |
+
"execution_count": 28,
|
| 1269 |
"metadata": {
|
| 1270 |
"id": "ZUKUqZsuumsp"
|
| 1271 |
},
|
|
|
|
| 1286 |
},
|
| 1287 |
{
|
| 1288 |
"cell_type": "code",
|
| 1289 |
+
"execution_count": 29,
|
| 1290 |
"metadata": {
|
| 1291 |
"colab": {
|
| 1292 |
"base_uri": "https://localhost:8080/"
|
| 1293 |
},
|
| 1294 |
"id": "3946e521",
|
| 1295 |
+
"outputId": "f50b5ec3-4143-4ff6-8596-5ef92ad874aa"
|
| 1296 |
},
|
| 1297 |
"outputs": [
|
| 1298 |
{
|
|
|
|
| 1418 |
},
|
| 1419 |
{
|
| 1420 |
"cell_type": "code",
|
| 1421 |
+
"execution_count": 30,
|
| 1422 |
"metadata": {
|
| 1423 |
"colab": {
|
| 1424 |
+
"base_uri": "https://localhost:8080/",
|
| 1425 |
+
"height": 206
|
| 1426 |
},
|
| 1427 |
"id": "xfE8NMqOurKo",
|
| 1428 |
+
"outputId": "fc16b2df-502f-4aaf-e6c9-63e3b2a4f83e"
|
| 1429 |
},
|
| 1430 |
"outputs": [
|
| 1431 |
{
|
| 1432 |
+
"output_type": "execute_result",
|
| 1433 |
+
"data": {
|
| 1434 |
+
"text/plain": [
|
| 1435 |
+
" title sentiment_label \\\n",
|
| 1436 |
+
"0 A Light in the Attic neutral \n",
|
| 1437 |
+
"1 A Light in the Attic neutral \n",
|
| 1438 |
+
"2 A Light in the Attic neutral \n",
|
| 1439 |
+
"3 Tipping the Velvet negative \n",
|
| 1440 |
+
"4 Tipping the Velvet negative \n",
|
| 1441 |
+
"\n",
|
| 1442 |
+
" review_text rating popularity_score \n",
|
| 1443 |
+
"0 An average book — not great, but not bad either. Three 3 \n",
|
| 1444 |
+
"1 Some parts really stood out, others felt a bit... Three 3 \n",
|
| 1445 |
+
"2 It was okay overall. A decent way to pass the ... Three 3 \n",
|
| 1446 |
+
"3 The plot was confusing and the characters felt... One 2 \n",
|
| 1447 |
+
"4 Disappointing. I had high hopes, but they were... One 2 "
|
| 1448 |
+
],
|
| 1449 |
+
"text/html": [
|
| 1450 |
+
"\n",
|
| 1451 |
+
" <div id=\"df-a985ad05-8a6d-442d-a94f-f2cdc781b1f7\" class=\"colab-df-container\">\n",
|
| 1452 |
+
" <div>\n",
|
| 1453 |
+
"<style scoped>\n",
|
| 1454 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1455 |
+
" vertical-align: middle;\n",
|
| 1456 |
+
" }\n",
|
| 1457 |
+
"\n",
|
| 1458 |
+
" .dataframe tbody tr th {\n",
|
| 1459 |
+
" vertical-align: top;\n",
|
| 1460 |
+
" }\n",
|
| 1461 |
+
"\n",
|
| 1462 |
+
" .dataframe thead th {\n",
|
| 1463 |
+
" text-align: right;\n",
|
| 1464 |
+
" }\n",
|
| 1465 |
+
"</style>\n",
|
| 1466 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1467 |
+
" <thead>\n",
|
| 1468 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1469 |
+
" <th></th>\n",
|
| 1470 |
+
" <th>title</th>\n",
|
| 1471 |
+
" <th>sentiment_label</th>\n",
|
| 1472 |
+
" <th>review_text</th>\n",
|
| 1473 |
+
" <th>rating</th>\n",
|
| 1474 |
+
" <th>popularity_score</th>\n",
|
| 1475 |
+
" </tr>\n",
|
| 1476 |
+
" </thead>\n",
|
| 1477 |
+
" <tbody>\n",
|
| 1478 |
+
" <tr>\n",
|
| 1479 |
+
" <th>0</th>\n",
|
| 1480 |
+
" <td>A Light in the Attic</td>\n",
|
| 1481 |
+
" <td>neutral</td>\n",
|
| 1482 |
+
" <td>An average book — not great, but not bad either.</td>\n",
|
| 1483 |
+
" <td>Three</td>\n",
|
| 1484 |
+
" <td>3</td>\n",
|
| 1485 |
+
" </tr>\n",
|
| 1486 |
+
" <tr>\n",
|
| 1487 |
+
" <th>1</th>\n",
|
| 1488 |
+
" <td>A Light in the Attic</td>\n",
|
| 1489 |
+
" <td>neutral</td>\n",
|
| 1490 |
+
" <td>Some parts really stood out, others felt a bit...</td>\n",
|
| 1491 |
+
" <td>Three</td>\n",
|
| 1492 |
+
" <td>3</td>\n",
|
| 1493 |
+
" </tr>\n",
|
| 1494 |
+
" <tr>\n",
|
| 1495 |
+
" <th>2</th>\n",
|
| 1496 |
+
" <td>A Light in the Attic</td>\n",
|
| 1497 |
+
" <td>neutral</td>\n",
|
| 1498 |
+
" <td>It was okay overall. A decent way to pass the ...</td>\n",
|
| 1499 |
+
" <td>Three</td>\n",
|
| 1500 |
+
" <td>3</td>\n",
|
| 1501 |
+
" </tr>\n",
|
| 1502 |
+
" <tr>\n",
|
| 1503 |
+
" <th>3</th>\n",
|
| 1504 |
+
" <td>Tipping the Velvet</td>\n",
|
| 1505 |
+
" <td>negative</td>\n",
|
| 1506 |
+
" <td>The plot was confusing and the characters felt...</td>\n",
|
| 1507 |
+
" <td>One</td>\n",
|
| 1508 |
+
" <td>2</td>\n",
|
| 1509 |
+
" </tr>\n",
|
| 1510 |
+
" <tr>\n",
|
| 1511 |
+
" <th>4</th>\n",
|
| 1512 |
+
" <td>Tipping the Velvet</td>\n",
|
| 1513 |
+
" <td>negative</td>\n",
|
| 1514 |
+
" <td>Disappointing. I had high hopes, but they were...</td>\n",
|
| 1515 |
+
" <td>One</td>\n",
|
| 1516 |
+
" <td>2</td>\n",
|
| 1517 |
+
" </tr>\n",
|
| 1518 |
+
" </tbody>\n",
|
| 1519 |
+
"</table>\n",
|
| 1520 |
+
"</div>\n",
|
| 1521 |
+
" <div class=\"colab-df-buttons\">\n",
|
| 1522 |
+
"\n",
|
| 1523 |
+
" <div class=\"colab-df-container\">\n",
|
| 1524 |
+
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a985ad05-8a6d-442d-a94f-f2cdc781b1f7')\"\n",
|
| 1525 |
+
" title=\"Convert this dataframe to an interactive table.\"\n",
|
| 1526 |
+
" style=\"display:none;\">\n",
|
| 1527 |
+
"\n",
|
| 1528 |
+
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
|
| 1529 |
+
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
|
| 1530 |
+
" </svg>\n",
|
| 1531 |
+
" </button>\n",
|
| 1532 |
+
"\n",
|
| 1533 |
+
" <style>\n",
|
| 1534 |
+
" .colab-df-container {\n",
|
| 1535 |
+
" display:flex;\n",
|
| 1536 |
+
" gap: 12px;\n",
|
| 1537 |
+
" }\n",
|
| 1538 |
+
"\n",
|
| 1539 |
+
" .colab-df-convert {\n",
|
| 1540 |
+
" background-color: #E8F0FE;\n",
|
| 1541 |
+
" border: none;\n",
|
| 1542 |
+
" border-radius: 50%;\n",
|
| 1543 |
+
" cursor: pointer;\n",
|
| 1544 |
+
" display: none;\n",
|
| 1545 |
+
" fill: #1967D2;\n",
|
| 1546 |
+
" height: 32px;\n",
|
| 1547 |
+
" padding: 0 0 0 0;\n",
|
| 1548 |
+
" width: 32px;\n",
|
| 1549 |
+
" }\n",
|
| 1550 |
+
"\n",
|
| 1551 |
+
" .colab-df-convert:hover {\n",
|
| 1552 |
+
" background-color: #E2EBFA;\n",
|
| 1553 |
+
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
|
| 1554 |
+
" fill: #174EA6;\n",
|
| 1555 |
+
" }\n",
|
| 1556 |
+
"\n",
|
| 1557 |
+
" .colab-df-buttons div {\n",
|
| 1558 |
+
" margin-bottom: 4px;\n",
|
| 1559 |
+
" }\n",
|
| 1560 |
+
"\n",
|
| 1561 |
+
" [theme=dark] .colab-df-convert {\n",
|
| 1562 |
+
" background-color: #3B4455;\n",
|
| 1563 |
+
" fill: #D2E3FC;\n",
|
| 1564 |
+
" }\n",
|
| 1565 |
+
"\n",
|
| 1566 |
+
" [theme=dark] .colab-df-convert:hover {\n",
|
| 1567 |
+
" background-color: #434B5C;\n",
|
| 1568 |
+
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
|
| 1569 |
+
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
|
| 1570 |
+
" fill: #FFFFFF;\n",
|
| 1571 |
+
" }\n",
|
| 1572 |
+
" </style>\n",
|
| 1573 |
+
"\n",
|
| 1574 |
+
" <script>\n",
|
| 1575 |
+
" const buttonEl =\n",
|
| 1576 |
+
" document.querySelector('#df-a985ad05-8a6d-442d-a94f-f2cdc781b1f7 button.colab-df-convert');\n",
|
| 1577 |
+
" buttonEl.style.display =\n",
|
| 1578 |
+
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
|
| 1579 |
+
"\n",
|
| 1580 |
+
" async function convertToInteractive(key) {\n",
|
| 1581 |
+
" const element = document.querySelector('#df-a985ad05-8a6d-442d-a94f-f2cdc781b1f7');\n",
|
| 1582 |
+
" const dataTable =\n",
|
| 1583 |
+
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
|
| 1584 |
+
" [key], {});\n",
|
| 1585 |
+
" if (!dataTable) return;\n",
|
| 1586 |
+
"\n",
|
| 1587 |
+
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
|
| 1588 |
+
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
|
| 1589 |
+
" + ' to learn more about interactive tables.';\n",
|
| 1590 |
+
" element.innerHTML = '';\n",
|
| 1591 |
+
" dataTable['output_type'] = 'display_data';\n",
|
| 1592 |
+
" await google.colab.output.renderOutput(dataTable, element);\n",
|
| 1593 |
+
" const docLink = document.createElement('div');\n",
|
| 1594 |
+
" docLink.innerHTML = docLinkHtml;\n",
|
| 1595 |
+
" element.appendChild(docLink);\n",
|
| 1596 |
+
" }\n",
|
| 1597 |
+
" </script>\n",
|
| 1598 |
+
" </div>\n",
|
| 1599 |
+
"\n",
|
| 1600 |
+
"\n",
|
| 1601 |
+
" </div>\n",
|
| 1602 |
+
" </div>\n"
|
| 1603 |
+
],
|
| 1604 |
+
"application/vnd.google.colaboratory.intrinsic+json": {
|
| 1605 |
+
"type": "dataframe",
|
| 1606 |
+
"variable_name": "df_reviews",
|
| 1607 |
+
"summary": "{\n \"name\": \"df_reviews\",\n \"rows\": 2520,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 799,\n \"samples\": [\n \"Where'd You Go, Bernadette\",\n \"Mockingjay (The Hunger Games #3)\",\n \"The Mindfulness and Acceptance Workbook for Anxiety: A Guide to Breaking Free from Anxiety, Phobias, and Worry Using Acceptance and Commitment Therapy\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"sentiment_label\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 3,\n \"samples\": [\n \"neutral\",\n \"negative\",\n \"positive\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"review_text\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 9,\n \"samples\": [\n \"A compelling and heartwarming read that stayed with me long after I finished.\",\n \"Some parts really stood out, others felt a bit flat.\",\n \"I struggled to get through this one \\u2014 it just didn\\u2019t grab me.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"One\",\n \"Two\",\n \"Four\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"popularity_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 1,\n \"max\": 5,\n \"num_unique_values\": 5,\n \"samples\": [\n 2,\n 5,\n 4\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
|
| 1608 |
+
}
|
| 1609 |
+
},
|
| 1610 |
+
"metadata": {},
|
| 1611 |
+
"execution_count": 30
|
| 1612 |
}
|
| 1613 |
],
|
| 1614 |
+
"source": [
|
| 1615 |
+
"df_reviews.head()"
|
| 1616 |
+
]
|
| 1617 |
}
|
| 1618 |
],
|
| 1619 |
"metadata": {
|
|
|
|
| 1621 |
"collapsed_sections": [
|
| 1622 |
"jpASMyIQMaAq",
|
| 1623 |
"lquNYCbfL9IM",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1624 |
"p-1Pr2szaqLk",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1625 |
"T8AdKkmASq9a",
|
| 1626 |
+
"7g9gqBgQMtJn"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1627 |
],
|
| 1628 |
"provenance": []
|
| 1629 |
},
|
pythonanalysis.ipynb
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|