Skip to content

Instantly share code, notes, and snippets.

@fenago
Created October 21, 2024 13:17
Show Gist options
  • Select an option

  • Save fenago/08b2440371a6db7515c8220ea19fff60 to your computer and use it in GitHub Desktop.

Select an option

Save fenago/08b2440371a6db7515c8220ea19fff60 to your computer and use it in GitHub Desktop.
proj_2-1_ramen.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/fenago/08b2440371a6db7515c8220ea19fff60/proj_2-1_ramen.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "t3Mp9NyoOb0D"
},
"source": [
"# Project 2-1: Analyze the ramen data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "delelQ2WOb0H"
},
"outputs": [],
"source": [
"# https://www.kaggle.com/residentmario/ramen-ratings\n",
"import pandas as pd\n",
"import seaborn as sns"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ac5MWkglOb0J"
},
"source": [
"## Tasks"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "QD0txreqOb0K"
},
"outputs": [],
"source": [
"# 1\n",
"data = pd.read_csv('ramen-ratings.csv')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1Gx-_JI7Ob0L",
"outputId": "4039509d-c969-43e5-8937-9429fca89cf2"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Brand</th>\n",
" <th>Variety</th>\n",
" <th>Style</th>\n",
" <th>Country</th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>New Touch</td>\n",
" <td>T's Restaurant Tantanmen</td>\n",
" <td>Cup</td>\n",
" <td>Japan</td>\n",
" <td>3.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Just Way</td>\n",
" <td>Noodles Spicy Hot Sesame Spicy Hot Sesame Guan...</td>\n",
" <td>Pack</td>\n",
" <td>Taiwan</td>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Nissin</td>\n",
" <td>Cup Noodles Chicken Vegetable</td>\n",
" <td>Cup</td>\n",
" <td>USA</td>\n",
" <td>2.25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Wei Lih</td>\n",
" <td>GGE Ramen Snack Tomato Flavor</td>\n",
" <td>Pack</td>\n",
" <td>Taiwan</td>\n",
" <td>2.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Ching's Secret</td>\n",
" <td>Singapore Curry</td>\n",
" <td>Pack</td>\n",
" <td>India</td>\n",
" <td>3.75</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Brand Variety Style \\\n",
"0 New Touch T's Restaurant Tantanmen Cup \n",
"1 Just Way Noodles Spicy Hot Sesame Spicy Hot Sesame Guan... Pack \n",
"2 Nissin Cup Noodles Chicken Vegetable Cup \n",
"3 Wei Lih GGE Ramen Snack Tomato Flavor Pack \n",
"4 Ching's Secret Singapore Curry Pack \n",
"\n",
" Country Stars \n",
"0 Japan 3.75 \n",
"1 Taiwan 1.00 \n",
"2 USA 2.25 \n",
"3 Taiwan 2.75 \n",
"4 India 3.75 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 2\n",
"data.head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "fhMBsk3pOb0N",
"outputId": "6b128d23-7a8a-4d37-c572-1adcf99953ec"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Brand</th>\n",
" <th>Variety</th>\n",
" <th>Style</th>\n",
" <th>Country</th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2572</th>\n",
" <td>Vifon</td>\n",
" <td>Hu Tiu Nam Vang [\"Phnom Penh\" style] Asian Sty...</td>\n",
" <td>Bowl</td>\n",
" <td>Vietnam</td>\n",
" <td>3.5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2573</th>\n",
" <td>Wai Wai</td>\n",
" <td>Oriental Style Instant Noodles</td>\n",
" <td>Pack</td>\n",
" <td>Thailand</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2574</th>\n",
" <td>Wai Wai</td>\n",
" <td>Tom Yum Shrimp</td>\n",
" <td>Pack</td>\n",
" <td>Thailand</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2575</th>\n",
" <td>Wai Wai</td>\n",
" <td>Tom Yum Chili Flavor</td>\n",
" <td>Pack</td>\n",
" <td>Thailand</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2576</th>\n",
" <td>Westbrae</td>\n",
" <td>Miso Ramen</td>\n",
" <td>Pack</td>\n",
" <td>USA</td>\n",
" <td>0.5</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Brand Variety Style \\\n",
"2572 Vifon Hu Tiu Nam Vang [\"Phnom Penh\" style] Asian Sty... Bowl \n",
"2573 Wai Wai Oriental Style Instant Noodles Pack \n",
"2574 Wai Wai Tom Yum Shrimp Pack \n",
"2575 Wai Wai Tom Yum Chili Flavor Pack \n",
"2576 Westbrae Miso Ramen Pack \n",
"\n",
" Country Stars \n",
"2572 Vietnam 3.5 \n",
"2573 Thailand 1.0 \n",
"2574 Thailand 2.0 \n",
"2575 Thailand 2.0 \n",
"2576 USA 0.5 "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 3\n",
"data.tail()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8ve-h5jHOb0O",
"outputId": "368ccfec-6413-451f-faad-0755aedef378"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>2577.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>mean</th>\n",
" <td>3.654676</td>\n",
" </tr>\n",
" <tr>\n",
" <th>std</th>\n",
" <td>1.015331</td>\n",
" </tr>\n",
" <tr>\n",
" <th>min</th>\n",
" <td>0.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25%</th>\n",
" <td>3.250000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50%</th>\n",
" <td>3.750000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75%</th>\n",
" <td>4.250000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>max</th>\n",
" <td>5.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Stars\n",
"count 2577.000000\n",
"mean 3.654676\n",
"std 1.015331\n",
"min 0.000000\n",
"25% 3.250000\n",
"50% 3.750000\n",
"75% 4.250000\n",
"max 5.000000"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 4\n",
"data.describe()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Big2LFp3Ob0P",
"outputId": "ae4d59d6-8987-4413-da9a-3a17b4ec6551"
},
"outputs": [
{
"data": {
"text/plain": [
"Brand 355\n",
"Variety 2410\n",
"Style 7\n",
"Country 38\n",
"Stars 42\n",
"dtype: int64"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 5\n",
"data.nunique()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "tYML0TgyOb0P",
"outputId": "6bf11952-e1fb-4dd9-bc68-3c486d969c80"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Brand</th>\n",
" <th>Variety</th>\n",
" <th>Style</th>\n",
" <th>Country</th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>Binh Tay</td>\n",
" <td>Mi Hai Cua</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>4.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>52</th>\n",
" <td>Uni-President</td>\n",
" <td>Mushroom Flavor</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>143</th>\n",
" <td>Mum Ngon</td>\n",
" <td>Lau Tom Chua Cay</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>3.50</td>\n",
" </tr>\n",
" <tr>\n",
" <th>224</th>\n",
" <td>Vifon</td>\n",
" <td>Viet Cuisine Bun Rieu Cua Sour Crab Soup Insta...</td>\n",
" <td>Bowl</td>\n",
" <td>Vietnam</td>\n",
" <td>5.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>365</th>\n",
" <td>Acecook</td>\n",
" <td>Oh! Ricey Pork Flavour</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>4.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2486</th>\n",
" <td>Binh Tay</td>\n",
" <td>Mi Chay Mushroom</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>2.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2535</th>\n",
" <td>Ve Wong</td>\n",
" <td>Kung-Fu Chicken Flavor</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>2.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2570</th>\n",
" <td>Ve Wong</td>\n",
" <td>Mushroom Pork</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2571</th>\n",
" <td>Vifon</td>\n",
" <td>Nam Vang</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>2.50</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2572</th>\n",
" <td>Vifon</td>\n",
" <td>Hu Tiu Nam Vang [\"Phnom Penh\" style] Asian Sty...</td>\n",
" <td>Bowl</td>\n",
" <td>Vietnam</td>\n",
" <td>3.50</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>108 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" Brand Variety Style \\\n",
"18 Binh Tay Mi Hai Cua Pack \n",
"52 Uni-President Mushroom Flavor Pack \n",
"143 Mum Ngon Lau Tom Chua Cay Pack \n",
"224 Vifon Viet Cuisine Bun Rieu Cua Sour Crab Soup Insta... Bowl \n",
"365 Acecook Oh! Ricey Pork Flavour Pack \n",
"... ... ... ... \n",
"2486 Binh Tay Mi Chay Mushroom Pack \n",
"2535 Ve Wong Kung-Fu Chicken Flavor Pack \n",
"2570 Ve Wong Mushroom Pork Pack \n",
"2571 Vifon Nam Vang Pack \n",
"2572 Vifon Hu Tiu Nam Vang [\"Phnom Penh\" style] Asian Sty... Bowl \n",
"\n",
" Country Stars \n",
"18 Vietnam 4.00 \n",
"52 Vietnam 0.00 \n",
"143 Vietnam 3.50 \n",
"224 Vietnam 5.00 \n",
"365 Vietnam 4.00 \n",
"... ... ... \n",
"2486 Vietnam 2.75 \n",
"2535 Vietnam 2.75 \n",
"2570 Vietnam 1.00 \n",
"2571 Vietnam 2.50 \n",
"2572 Vietnam 3.50 \n",
"\n",
"[108 rows x 5 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 6\n",
"data.query('Country == \"Vietnam\"')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "tVMWCBNFOb0Q",
"outputId": "da623190-4e3e-4a5a-9798-6dc4a2864864"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Brand</th>\n",
" <th>Style</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>New Touch</td>\n",
" <td>Cup</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Just Way</td>\n",
" <td>Pack</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Nissin</td>\n",
" <td>Cup</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Wei Lih</td>\n",
" <td>Pack</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Ching's Secret</td>\n",
" <td>Pack</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2572</th>\n",
" <td>Vifon</td>\n",
" <td>Bowl</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2573</th>\n",
" <td>Wai Wai</td>\n",
" <td>Pack</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2574</th>\n",
" <td>Wai Wai</td>\n",
" <td>Pack</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2575</th>\n",
" <td>Wai Wai</td>\n",
" <td>Pack</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2576</th>\n",
" <td>Westbrae</td>\n",
" <td>Pack</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>2577 rows × 2 columns</p>\n",
"</div>"
],
"text/plain": [
" Brand Style\n",
"0 New Touch Cup\n",
"1 Just Way Pack\n",
"2 Nissin Cup\n",
"3 Wei Lih Pack\n",
"4 Ching's Secret Pack\n",
"... ... ...\n",
"2572 Vifon Bowl\n",
"2573 Wai Wai Pack\n",
"2574 Wai Wai Pack\n",
"2575 Wai Wai Pack\n",
"2576 Westbrae Pack\n",
"\n",
"[2577 rows x 2 columns]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 7\n",
"data[['Brand','Style']]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "A8z3c2YKOb0R",
"outputId": "89c8ad85-ef54-449f-f4d6-e319a4985850"
},
"outputs": [
{
"data": {
"text/plain": [
"0 Japan\n",
"1 Taiwan\n",
"2 USA\n",
"3 Taiwan\n",
"4 India\n",
" ... \n",
"2572 Vietnam\n",
"2573 Thailand\n",
"2574 Thailand\n",
"2575 Thailand\n",
"2576 USA\n",
"Name: Country, Length: 2577, dtype: object"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 8\n",
"data.Country"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "JecD6LegOb0S",
"outputId": "01edafad-bb57-4ffa-da2e-8397a8c9a21a"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Brand</th>\n",
" <th>Variety</th>\n",
" <th>Style</th>\n",
" <th>Country</th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1585</th>\n",
" <td>Prima Taste</td>\n",
" <td>Singapore Laksa La Mian</td>\n",
" <td>Pack</td>\n",
" <td>Singapore</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>446</th>\n",
" <td>Maruchan</td>\n",
" <td>Instant Lunch Chipotle Chicken Flavor Ramen No...</td>\n",
" <td>Cup</td>\n",
" <td>USA</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>484</th>\n",
" <td>Nongshim</td>\n",
" <td>Champong Noodle Soup Spicy Seafood Flavor</td>\n",
" <td>Pack</td>\n",
" <td>South Korea</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>483</th>\n",
" <td>Nissin</td>\n",
" <td>Straits Kitchen Laksa</td>\n",
" <td>Pack</td>\n",
" <td>Singapore</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1613</th>\n",
" <td>Nissin</td>\n",
" <td>Raoh Backfat Rich Soy Sauce Flavor</td>\n",
" <td>Bowl</td>\n",
" <td>Japan</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>522</th>\n",
" <td>Koyo</td>\n",
" <td>Garlic Pepper Reduced Sodium Ramen</td>\n",
" <td>Pack</td>\n",
" <td>USA</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>561</th>\n",
" <td>Samyang Foods</td>\n",
" <td>Honey &amp; Cheese Big Bowl</td>\n",
" <td>Bowl</td>\n",
" <td>South Korea</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>950</th>\n",
" <td>Azami</td>\n",
" <td>Kimchee Noodle Soup</td>\n",
" <td>Cup</td>\n",
" <td>Canada</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2079</th>\n",
" <td>Hsin Tung Yang</td>\n",
" <td>Tiny Noodle With Oyster Flavor</td>\n",
" <td>Pack</td>\n",
" <td>Taiwan</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>52</th>\n",
" <td>Uni-President</td>\n",
" <td>Mushroom Flavor</td>\n",
" <td>Pack</td>\n",
" <td>Vietnam</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>2577 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" Brand Variety Style \\\n",
"1585 Prima Taste Singapore Laksa La Mian Pack \n",
"446 Maruchan Instant Lunch Chipotle Chicken Flavor Ramen No... Cup \n",
"484 Nongshim Champong Noodle Soup Spicy Seafood Flavor Pack \n",
"483 Nissin Straits Kitchen Laksa Pack \n",
"1613 Nissin Raoh Backfat Rich Soy Sauce Flavor Bowl \n",
"... ... ... ... \n",
"522 Koyo Garlic Pepper Reduced Sodium Ramen Pack \n",
"561 Samyang Foods Honey & Cheese Big Bowl Bowl \n",
"950 Azami Kimchee Noodle Soup Cup \n",
"2079 Hsin Tung Yang Tiny Noodle With Oyster Flavor Pack \n",
"52 Uni-President Mushroom Flavor Pack \n",
"\n",
" Country Stars \n",
"1585 Singapore 5.0 \n",
"446 USA 5.0 \n",
"484 South Korea 5.0 \n",
"483 Singapore 5.0 \n",
"1613 Japan 5.0 \n",
"... ... ... \n",
"522 USA 0.0 \n",
"561 South Korea 0.0 \n",
"950 Canada 0.0 \n",
"2079 Taiwan 0.0 \n",
"52 Vietnam 0.0 \n",
"\n",
"[2577 rows x 5 columns]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 9\n",
"data.sort_values('Stars', ascending=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "sOhNzN8JOb0T",
"outputId": "896842bc-79a5-4e1a-ce94-5f94405231b5"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Brand</th>\n",
" <th>Variety</th>\n",
" <th>Style</th>\n",
" <th>Country</th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>New Touch</td>\n",
" <td>T's Restaurant Tantanmen</td>\n",
" <td>Cup</td>\n",
" <td>Japan</td>\n",
" <td>3.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Just Way</td>\n",
" <td>Noodles Spicy Hot Sesame Spicy Hot Sesame Guan...</td>\n",
" <td>Pack</td>\n",
" <td>Taiwan</td>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Nissin</td>\n",
" <td>Cup Noodles Chicken Vegetable</td>\n",
" <td>Cup</td>\n",
" <td>United States</td>\n",
" <td>2.25</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Wei Lih</td>\n",
" <td>GGE Ramen Snack Tomato Flavor</td>\n",
" <td>Pack</td>\n",
" <td>Taiwan</td>\n",
" <td>2.75</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Ching's Secret</td>\n",
" <td>Singapore Curry</td>\n",
" <td>Pack</td>\n",
" <td>India</td>\n",
" <td>3.75</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Brand Variety Style \\\n",
"0 New Touch T's Restaurant Tantanmen Cup \n",
"1 Just Way Noodles Spicy Hot Sesame Spicy Hot Sesame Guan... Pack \n",
"2 Nissin Cup Noodles Chicken Vegetable Cup \n",
"3 Wei Lih GGE Ramen Snack Tomato Flavor Pack \n",
"4 Ching's Secret Singapore Curry Pack \n",
"\n",
" Country Stars \n",
"0 Japan 3.75 \n",
"1 Taiwan 1.00 \n",
"2 United States 2.25 \n",
"3 Taiwan 2.75 \n",
"4 India 3.75 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 10\n",
"data.Country.replace('USA','United States', inplace=True)\n",
"data.head()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ws9Y2uD3Ob0T"
},
"source": [
"## Questions"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "FOF77FR7Ob0U",
"outputId": "157e72b1-0f7f-47b0-d428-adee270111cf"
},
"outputs": [
{
"data": {
"text/plain": [
"37"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 1\n",
"data.Country.nunique()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "hRkkCYEaOb0U",
"outputId": "b963b264-fb56-416c-d613-bf8a3402f6ff"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Brazil</th>\n",
" <td>4.350000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Sarawak</th>\n",
" <td>4.333333</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Cambodia</th>\n",
" <td>4.200000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Stars\n",
"Country \n",
"Brazil 4.350000\n",
"Sarawak 4.333333\n",
"Cambodia 4.200000"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 2\n",
"data.groupby('Country').mean().sort_values('Stars', ascending=False).head(3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Md5vGUukOb0V",
"outputId": "88b01f2e-c48e-4e9b-8095-56d4bfe15f04"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Stars</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Nigeria</th>\n",
" <td>1.500000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Canada</th>\n",
" <td>2.243902</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Netherlands</th>\n",
" <td>2.483333</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Stars\n",
"Country \n",
"Nigeria 1.500000\n",
"Canada 2.243902\n",
"Netherlands 2.483333"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 3\n",
"data.groupby('Country').mean().sort_values('Stars').head(3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "GA6azE5nOb0V",
"outputId": "5b905640-8ebc-4da8-982d-982d1e9d8a62"
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Brand</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Country</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Japan</th>\n",
" <td>352</td>\n",
" </tr>\n",
" <tr>\n",
" <th>United States</th>\n",
" <td>324</td>\n",
" </tr>\n",
" <tr>\n",
" <th>South Korea</th>\n",
" <td>307</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Brand\n",
"Country \n",
"Japan 352\n",
"United States 324\n",
"South Korea 307"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 4\n",
"data.groupby('Country').count()[['Brand']].sort_values('Brand', ascending=False).head(3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "_RMmuj2BOb0W"
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
},
"colab": {
"provenance": [],
"include_colab_link": true
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment