{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "EDS_2020_2021_Python_Intro2Pandas.ipynb", "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "tnhlRZWVFSg6" }, "source": [ "# Pandas: a convenient library for data science\n", "\n", "In this notebook, it's out of questions to reinvent what has been already done thousands of times. Nevertheless, one can focus on the usesul commands which will be used during the *Earth Data Sciences* practical activities.\n", "\n", "\n", "Pandas is part of the anaconda toolbox. So if it's already installed, you have nothing to do but importing the Pandas library just writing:\n" ] }, { "cell_type": "code", "metadata": { "id": "uwByVDrVGtDl" }, "source": [ "import pandas as pd" ], "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "NFc5khEnG18h" }, "source": [ "Pandas is made of two core objects : The **Dataframes** and the **Series**\n", "Let's see that in details.\n" ] }, { "cell_type": "markdown", "metadata": { "id": "ar5IlSu5HKMV" }, "source": [ "## DataFrame\n", "\n", "Roughly, DataFrame object is a table ie, an array with some entries made of values" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 143 }, "id": "_pTHEJ4CHqTy", "outputId": "05c864a9-4322-4f04-bb6c-c352cab6e43e" }, "source": [ "myfirstdataframe = pd.DataFrame({\"Hero\":[\"SpiderMan\", \"Captain America\", \"Iron Man\"], \"Hair\":[\"Brown\", \"Blond\", \"Black\"]}, )\n", "display(myfirstdataframe)" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "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>Hero</th>\n", " <th>Hair</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>SpiderMan</td>\n", " <td>Brown</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>Captain America</td>\n", " <td>Blond</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>Iron Man</td>\n", " <td>Black</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Hero Hair\n", "0 SpiderMan Brown\n", "1 Captain America Blond\n", "2 Iron Man Black" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "markdown", "metadata": { "id": "JyOSGct8K5eI" }, "source": [ "Of course, entries can be either strings, integers, floats... \n", "\n", "In the previous example, indexes are (0, 1, 2). It can be customed using the keyword **index**\n", "\n" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 161 }, "id": "uBY6nGrxODR8", "outputId": "09f18e01-86f7-4c0c-9e2b-cdd625ec994a" }, "source": [ "myfirstdataframe = pd.DataFrame({\"Hero\":[\"SpiderMan\", \"Captain America\", \"Iron Man\"], \"Hair\":[\"Brown\", \"Blond\", \"Black\"]}, \n", " [\"Hero 1\", \"Hero 2\", \"Hero 3\"])\n", "display(myfirstdataframe)\n", "type(myfirstdataframe)" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "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>Hero</th>\n", " <th>Hair</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>Hero 1</th>\n", " <td>SpiderMan</td>\n", " <td>Brown</td>\n", " </tr>\n", " <tr>\n", " <th>Hero 2</th>\n", " <td>Captain America</td>\n", " <td>Blond</td>\n", " </tr>\n", " <tr>\n", " <th>Hero 3</th>\n", " <td>Iron Man</td>\n", " <td>Black</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Hero Hair\n", "Hero 1 SpiderMan Brown\n", "Hero 2 Captain America Blond\n", "Hero 3 Iron Man Black" ] }, "metadata": { "tags": [] } }, { "output_type": "execute_result", "data": { "text/plain": [ "pandas.core.frame.DataFrame" ] }, "metadata": { "tags": [] }, "execution_count": 36 } ] }, { "cell_type": "markdown", "metadata": { "id": "25fge8ivLJ4z" }, "source": [ "### Exercice 1: \n", "Create a DataFrame *fruits* with the following entries\n", "\n", "| |Apples|Bananas|Strawberries|\n", "| -------- | -------- | -------- | -------- | \n", "|Basket 1 | 12| 34| 45|\n", "|Basket 2 | 26| 18| 89|" ] }, { "cell_type": "code", "metadata": { "id": "7eff1u4xMrG1" }, "source": [ "# Insert your code here, then test it " ], "execution_count": null, "outputs": [] }, { "cell_type": "markdown", "metadata": { "id": "QC8GzLiWOdru" }, "source": [ "### Solution\n", "Click below for a solution. " ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 112 }, "id": "AmGwdHb5MvP6", "outputId": "79ed4398-9f46-4c36-bb14-2dc6c6c80e3e" }, "source": [ "fruits = pd.DataFrame({\"Apples\":[12,26], \"Bananas\":[34,18], \"Strawberries\":[45,89]}, index = [\"Basket 1\", \"Basket 2\"])\n", "display(fruits)" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "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>Apples</th>\n", " <th>Bananas</th>\n", " <th>Strawberries</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>Basket 1</th>\n", " <td>12</td>\n", " <td>34</td>\n", " <td>45</td>\n", " </tr>\n", " <tr>\n", " <th>Basket 2</th>\n", " <td>26</td>\n", " <td>18</td>\n", " <td>89</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Apples Bananas Strawberries\n", "Basket 1 12 34 45\n", "Basket 2 26 18 89" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "markdown", "metadata": { "id": "LunpDLOfO6xf" }, "source": [ "## Series objects\n", "\n", "In fact, it's a one column DataFrame.\n" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 88 }, "id": "igpLBysYPHkI", "outputId": "b88fd1ee-4bf5-43ff-d70a-6b3078a25b0e" }, "source": [ "s1 = pd.Series([299792458, 6.62607015e-34, 1.380649e-23], index=[\"Célérité de la lumière dans le vide\", \"Constante de Planck\", \"Constante de Boltzmann\"])\n", "display(s1)\n" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "Célérité de la lumière dans le vide 2.997925e+08\n", "Constante de Planck 6.626070e-34\n", "Constante de Boltzmann 1.380649e-23\n", "dtype: float64" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "wOSGXUHYQIot", "outputId": "a16db951-db2b-4686-dba5-4ab4bb5f2011" }, "source": [ "type(s1)" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "pandas.core.series.Series" ] }, "metadata": { "tags": [] }, "execution_count": 39 } ] }, { "cell_type": "markdown", "metadata": { "id": "TYXJILb9Ssgb" }, "source": [ "Just to make sure, if one extract the first column from the previous DataFrame" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 70 }, "id": "U_vrOVSlSZy6", "outputId": "ffd174c3-2162-4928-9837-5c87cbabcb2b" }, "source": [ "Apple = fruits[\"Apples\"]\n", "display (Apple)\n" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ "Basket 1 12\n", "Basket 2 26\n", "Name: Apples, dtype: int64" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "RijLvIA0SpGI", "outputId": "8764fddc-dac6-4b3d-9b0e-7cfaf1b9dbde" }, "source": [ "type(Apple)" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "pandas.core.series.Series" ] }, "metadata": { "tags": [] }, "execution_count": 42 } ] }, { "cell_type": "markdown", "metadata": { "id": "OUyLvD2jS14i" }, "source": [ "But the most interesting part is to read text, cvs files to convert them into Pandas DataFrames. " ] }, { "cell_type": "markdown", "metadata": { "id": "6yLQ_InzTAl0" }, "source": [ "## From files to DataFrames\n", "\n", "Here, we are reading a dataset took from Kaggle about indian food.\n", "\n", "\n" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 363 }, "id": "S5MQPKSPUFjN", "outputId": "4235b79a-b7a6-4922-d9a3-4f063f2e00e8" }, "source": [ "\n", "indian_food = pd.read_csv(\"indian_food.csv\")\n" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "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>name</th>\n", " <th>ingredients</th>\n", " <th>diet</th>\n", " <th>prep_time</th>\n", " <th>cook_time</th>\n", " <th>flavor_profile</th>\n", " <th>course</th>\n", " <th>state</th>\n", " <th>region</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>Balu shahi</td>\n", " <td>Maida flour, yogurt, oil, sugar</td>\n", " <td>vegetarian</td>\n", " <td>45</td>\n", " <td>25</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>Boondi</td>\n", " <td>Gram flour, ghee, sugar</td>\n", " <td>vegetarian</td>\n", " <td>80</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>Gajar ka halwa</td>\n", " <td>Carrots, milk, sugar, ghee, cashews, raisins</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>60</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Punjab</td>\n", " <td>North</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>Ghevar</td>\n", " <td>Flour, ghee, kewra, milk, clarified butter, su...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>Gulab jamun</td>\n", " <td>Milk powder, plain flour, baking powder, ghee,...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>40</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>5</th>\n", " <td>Imarti</td>\n", " <td>Sugar syrup, lentil flour</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>50</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>6</th>\n", " <td>Jalebi</td>\n", " <td>Maida, corn flour, baking soda, vinegar, curd,...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>50</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Uttar Pradesh</td>\n", " <td>North</td>\n", " </tr>\n", " <tr>\n", " <th>7</th>\n", " <td>Kaju katli</td>\n", " <td>Cashews, ghee, cardamom, sugar</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>20</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " </tr>\n", " <tr>\n", " <th>8</th>\n", " <td>Kalakand</td>\n", " <td>Milk, cottage cheese, sugar</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>9</th>\n", " <td>Kheer</td>\n", " <td>Milk, rice, sugar, dried fruits</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>40</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " name ... region\n", "0 Balu shahi ... East\n", "1 Boondi ... West\n", "2 Gajar ka halwa ... North\n", "3 Ghevar ... West\n", "4 Gulab jamun ... East\n", "5 Imarti ... East\n", "6 Jalebi ... North\n", "7 Kaju katli ... -1\n", "8 Kalakand ... East\n", "9 Kheer ... -1\n", "\n", "[10 rows x 9 columns]" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "markdown", "metadata": { "id": "QDDe_WnNUjQo" }, "source": [ "# Useful commands to analyze your sets of data\n", "\n", "- head()\n", "- tail()\n", "- info()\n", "- describe()\n", "- shape" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "DcBUB5cWUyJb", "outputId": "bd4d80e3-9a9a-4571-a452-d33b9663d422" }, "source": [ "# The first entries\n", "display(indian_food.head()) # Default number of lines is 5. You can change by myset.head(mynumber)" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "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>name</th>\n", " <th>ingredients</th>\n", " <th>diet</th>\n", " <th>prep_time</th>\n", " <th>cook_time</th>\n", " <th>flavor_profile</th>\n", " <th>course</th>\n", " <th>state</th>\n", " <th>region</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>Balu shahi</td>\n", " <td>Maida flour, yogurt, oil, sugar</td>\n", " <td>vegetarian</td>\n", " <td>45</td>\n", " <td>25</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>Boondi</td>\n", " <td>Gram flour, ghee, sugar</td>\n", " <td>vegetarian</td>\n", " <td>80</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>Gajar ka halwa</td>\n", " <td>Carrots, milk, sugar, ghee, cashews, raisins</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>60</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Punjab</td>\n", " <td>North</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>Ghevar</td>\n", " <td>Flour, ghee, kewra, milk, clarified butter, su...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>Gulab jamun</td>\n", " <td>Milk powder, plain flour, baking powder, ghee,...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>40</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " name ... region\n", "0 Balu shahi ... East\n", "1 Boondi ... West\n", "2 Gajar ka halwa ... North\n", "3 Ghevar ... West\n", "4 Gulab jamun ... East\n", "\n", "[5 rows x 9 columns]" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "_aQSax4qU23Q", "outputId": "c9a3845a-7c96-4982-cc3f-8504a37a657f" }, "source": [ "# The last entries\n", "display(indian_food.tail())" ], "execution_count": null, "outputs": [ { "output_type": "display_data", "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>name</th>\n", " <th>ingredients</th>\n", " <th>diet</th>\n", " <th>prep_time</th>\n", " <th>cook_time</th>\n", " <th>flavor_profile</th>\n", " <th>course</th>\n", " <th>state</th>\n", " <th>region</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>250</th>\n", " <td>Til Pitha</td>\n", " <td>Glutinous rice, black sesame seeds, gur</td>\n", " <td>vegetarian</td>\n", " <td>5</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Assam</td>\n", " <td>North East</td>\n", " </tr>\n", " <tr>\n", " <th>251</th>\n", " <td>Bebinca</td>\n", " <td>Coconut milk, egg yolks, clarified butter, all...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>60</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Goa</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>252</th>\n", " <td>Shufta</td>\n", " <td>Cottage cheese, dry dates, dried rose petals, ...</td>\n", " <td>vegetarian</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Jammu & Kashmir</td>\n", " <td>North</td>\n", " </tr>\n", " <tr>\n", " <th>253</th>\n", " <td>Mawa Bati</td>\n", " <td>Milk powder, dry fruits, arrowroot powder, all...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>45</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Madhya Pradesh</td>\n", " <td>Central</td>\n", " </tr>\n", " <tr>\n", " <th>254</th>\n", " <td>Pinaca</td>\n", " <td>Brown rice, fennel seeds, grated coconut, blac...</td>\n", " <td>vegetarian</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Goa</td>\n", " <td>West</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " name ... region\n", "250 Til Pitha ... North East\n", "251 Bebinca ... West\n", "252 Shufta ... North\n", "253 Mawa Bati ... Central\n", "254 Pinaca ... West\n", "\n", "[5 rows x 9 columns]" ] }, "metadata": { "tags": [] } } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "EfNcGXAMVBf_", "outputId": "2667ed46-e9a4-42c1-8669-62573656b304" }, "source": [ "# This one is very useful to check the type of data, the size of each column.\n", "# \n", "indian_food.info()" ], "execution_count": null, "outputs": [ { "output_type": "stream", "text": [ "<class 'pandas.core.frame.DataFrame'>\n", "RangeIndex: 255 entries, 0 to 254\n", "Data columns (total 9 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 name 255 non-null object\n", " 1 ingredients 255 non-null object\n", " 2 diet 255 non-null object\n", " 3 prep_time 255 non-null int64 \n", " 4 cook_time 255 non-null int64 \n", " 5 flavor_profile 255 non-null object\n", " 6 course 255 non-null object\n", " 7 state 255 non-null object\n", " 8 region 254 non-null object\n", "dtypes: int64(2), object(7)\n", "memory usage: 18.1+ KB\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 300 }, "id": "zcVv5lLkVnN8", "outputId": "8d867355-04a6-4e67-f446-9d5fad91aa4f" }, "source": [ "# Describe function is only available for numeric columns.\n", "indian_food.describe()" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "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>prep_time</th>\n", " <th>cook_time</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>count</th>\n", " <td>255.000000</td>\n", " <td>255.000000</td>\n", " </tr>\n", " <tr>\n", " <th>mean</th>\n", " <td>31.105882</td>\n", " <td>34.529412</td>\n", " </tr>\n", " <tr>\n", " <th>std</th>\n", " <td>72.554409</td>\n", " <td>48.265650</td>\n", " </tr>\n", " <tr>\n", " <th>min</th>\n", " <td>-1.000000</td>\n", " <td>-1.000000</td>\n", " </tr>\n", " <tr>\n", " <th>25%</th>\n", " <td>10.000000</td>\n", " <td>20.000000</td>\n", " </tr>\n", " <tr>\n", " <th>50%</th>\n", " <td>10.000000</td>\n", " <td>30.000000</td>\n", " </tr>\n", " <tr>\n", " <th>75%</th>\n", " <td>20.000000</td>\n", " <td>40.000000</td>\n", " </tr>\n", " <tr>\n", " <th>max</th>\n", " <td>500.000000</td>\n", " <td>720.000000</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " prep_time cook_time\n", "count 255.000000 255.000000\n", "mean 31.105882 34.529412\n", "std 72.554409 48.265650\n", "min -1.000000 -1.000000\n", "25% 10.000000 20.000000\n", "50% 10.000000 30.000000\n", "75% 20.000000 40.000000\n", "max 500.000000 720.000000" ] }, "metadata": { "tags": [] }, "execution_count": 50 } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "gBt5D49idiE1", "outputId": "d0753dd0-8eaa-43c3-d7a3-7ebcd54aa402" }, "source": [ "# It's possible to restrict the choice to one column only \n", "indian_food.prep_time.describe()" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "count 255.000000\n", "mean 31.105882\n", "std 72.554409\n", "min -1.000000\n", "25% 10.000000\n", "50% 10.000000\n", "75% 20.000000\n", "max 500.000000\n", "Name: prep_time, dtype: float64" ] }, "metadata": { "tags": [] }, "execution_count": 66 } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "ou7tifeOWjBd", "outputId": "4148c33f-4eb8-418e-ba2d-1c0a01cddabd" }, "source": [ "# Of course, one can get the shape of the dataset\n", "indian_food.shape" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "(255, 9)" ] }, "metadata": { "tags": [] }, "execution_count": 51 } ] }, { "cell_type": "markdown", "metadata": { "id": "udznYbQAd47X" }, "source": [ "If you want to check the number of occurence for a given field, we can use `value_counts()`" ] }, { "cell_type": "code", "metadata": { "id": "SJj3SRbheFfd", "outputId": "50ff3a11-a2a3-48b1-c621-db10d388ed4b", "colab": { "base_uri": "https://localhost:8080/" } }, "source": [ "indian_food.state.value_counts()" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "Gujarat 35\n", "Punjab 32\n", "Maharashtra 30\n", "-1 24\n", "West Bengal 24\n", "Assam 21\n", "Tamil Nadu 20\n", "Andhra Pradesh 10\n", "Uttar Pradesh 9\n", "Kerala 8\n", "Odisha 7\n", "Karnataka 6\n", "Rajasthan 6\n", "Telangana 5\n", "Goa 3\n", "Bihar 3\n", "Jammu & Kashmir 2\n", "Manipur 2\n", "Madhya Pradesh 2\n", "NCT of Delhi 1\n", "Tripura 1\n", "Nagaland 1\n", "Chhattisgarh 1\n", "Uttarakhand 1\n", "Haryana 1\n", "Name: state, dtype: int64" ] }, "metadata": { "tags": [] }, "execution_count": 67 } ] }, { "cell_type": "markdown", "metadata": { "id": "tNbjcxIxV3jT" }, "source": [ "# Indexing and selecting the data\n", "\n", "It's now time to see how to select any data in the DataFrame. \n" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "tk7KY6f9XRuK", "outputId": "91084cc4-7a78-4734-dc7c-e79817986d37" }, "source": [ "# Let's see how to get the name of the recipes. They are stored in the field \"name\"\n", "indian_food.name # or indian_food[\"name\"]\n", "\n" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0 Balu shahi\n", "1 Boondi\n", "2 Gajar ka halwa\n", "3 Ghevar\n", "4 Gulab jamun\n", " ... \n", "250 Til Pitha\n", "251 Bebinca\n", "252 Shufta\n", "253 Mawa Bati\n", "254 Pinaca\n", "Name: name, Length: 255, dtype: object" ] }, "metadata": { "tags": [] }, "execution_count": 52 } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 36 }, "id": "aFi6WfpzXnQK", "outputId": "bfa95b6d-82ce-48ce-e4fc-3dc89536ada5" }, "source": [ "# Find the name of the 4th recipe\n", "indian_food[\"name\"][3]\n" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "application/vnd.google.colaboratory.intrinsic+json": { "type": "string" }, "text/plain": [ "'Ghevar'" ] }, "metadata": { "tags": [] }, "execution_count": 54 } ] }, { "cell_type": "markdown", "metadata": { "id": "a-iqFimHYAg5" }, "source": [ "## Indexing with `iloc` and `loc`\n" ] }, { "cell_type": "markdown", "metadata": { "id": "0F6xW3KmaBWV" }, "source": [ "### `iloc`: the index-based selection\n", "\n", "You select the data by their numerical position in the data." ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "3tAiHVnMYtbB", "outputId": "af379b76-a97d-4ef2-a77a-bc0afb98f05e" }, "source": [ "# For example, the second entry.\n", "indian_food.iloc[1]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "name Boondi\n", "ingredients Gram flour, ghee, sugar\n", "diet vegetarian\n", "prep_time 80\n", "cook_time 30\n", "flavor_profile sweet\n", "course dessert\n", "state Rajasthan\n", "region West\n", "Name: 1, dtype: object" ] }, "metadata": { "tags": [] }, "execution_count": 55 } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 363 }, "id": "5CAXTb8mY7Qn", "outputId": "03cc8ebc-4748-4b4f-c767-9042873fb1fa" }, "source": [ "# Another example, 2nd to 12th entries\n", "indian_food.iloc[1:11]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "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>name</th>\n", " <th>ingredients</th>\n", " <th>diet</th>\n", " <th>prep_time</th>\n", " <th>cook_time</th>\n", " <th>flavor_profile</th>\n", " <th>course</th>\n", " <th>state</th>\n", " <th>region</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>1</th>\n", " <td>Boondi</td>\n", " <td>Gram flour, ghee, sugar</td>\n", " <td>vegetarian</td>\n", " <td>80</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>Gajar ka halwa</td>\n", " <td>Carrots, milk, sugar, ghee, cashews, raisins</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>60</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Punjab</td>\n", " <td>North</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>Ghevar</td>\n", " <td>Flour, ghee, kewra, milk, clarified butter, su...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>Gulab jamun</td>\n", " <td>Milk powder, plain flour, baking powder, ghee,...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>40</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>5</th>\n", " <td>Imarti</td>\n", " <td>Sugar syrup, lentil flour</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>50</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>6</th>\n", " <td>Jalebi</td>\n", " <td>Maida, corn flour, baking soda, vinegar, curd,...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>50</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Uttar Pradesh</td>\n", " <td>North</td>\n", " </tr>\n", " <tr>\n", " <th>7</th>\n", " <td>Kaju katli</td>\n", " <td>Cashews, ghee, cardamom, sugar</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>20</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " </tr>\n", " <tr>\n", " <th>8</th>\n", " <td>Kalakand</td>\n", " <td>Milk, cottage cheese, sugar</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>West Bengal</td>\n", " <td>East</td>\n", " </tr>\n", " <tr>\n", " <th>9</th>\n", " <td>Kheer</td>\n", " <td>Milk, rice, sugar, dried fruits</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>40</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " </tr>\n", " <tr>\n", " <th>10</th>\n", " <td>Laddu</td>\n", " <td>Gram flour, ghee, sugar</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>40</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " name ... region\n", "1 Boondi ... West\n", "2 Gajar ka halwa ... North\n", "3 Ghevar ... West\n", "4 Gulab jamun ... East\n", "5 Imarti ... East\n", "6 Jalebi ... North\n", "7 Kaju katli ... -1\n", "8 Kalakand ... East\n", "9 Kheer ... -1\n", "10 Laddu ... -1\n", "\n", "[10 rows x 9 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 58 } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "D-x3KNerZjxa", "outputId": "ddf094e2-855e-4c0d-8db8-5adb394f73ff" }, "source": [ "# From the previous example, i just want the ingredients\n", "indian_food.iloc[1:11, 1]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "1 Gram flour, ghee, sugar\n", "2 Carrots, milk, sugar, ghee, cashews, raisins\n", "3 Flour, ghee, kewra, milk, clarified butter, su...\n", "4 Milk powder, plain flour, baking powder, ghee,...\n", "5 Sugar syrup, lentil flour\n", "6 Maida, corn flour, baking soda, vinegar, curd,...\n", "7 Cashews, ghee, cardamom, sugar\n", "8 Milk, cottage cheese, sugar\n", "9 Milk, rice, sugar, dried fruits\n", "10 Gram flour, ghee, sugar\n", "Name: ingredients, dtype: object" ] }, "metadata": { "tags": [] }, "execution_count": 59 } ] }, { "cell_type": "markdown", "metadata": { "id": "hbuGF27PYrXN" }, "source": [ "### `loc`: the label selection\n", "\n", "You select the data by their index data and not the position." ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 36 }, "id": "3uYz0GB0ap3v", "outputId": "8a57c809-a28a-4a42-a764-220ee9839aac" }, "source": [ "# For example, i want to extract origin state of the recipe at index 5\n", "indian_food.loc[5,\"state\"]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "application/vnd.google.colaboratory.intrinsic+json": { "type": "string" }, "text/plain": [ "'West Bengal'" ] }, "metadata": { "tags": [] }, "execution_count": 61 } ] }, { "cell_type": "markdown", "metadata": { "id": "d3IbIYmlbXpo" }, "source": [ "## Selecting data\n", "\n", "The most interesting part of Pandas is to select the data with some easy to use conditionnal statements" ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "HLMwxn0cbu4q", "outputId": "af0cc9a9-51f7-4341-f966-9b31d2125ebc" }, "source": [ "# For example, select the recipes from the West\n", "indian_food.region == \"West\" # It creates a mask for your data" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "0 False\n", "1 True\n", "2 False\n", "3 True\n", "4 False\n", " ... \n", "250 False\n", "251 True\n", "252 False\n", "253 False\n", "254 True\n", "Name: region, Length: 255, dtype: bool" ] }, "metadata": { "tags": [] }, "execution_count": 62 } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "id": "_zfH4uHhcF4z", "outputId": "50d24193-910b-4634-8821-2780cba06437" }, "source": [ "# Select the data with the previous mask.\n", "indian_food[indian_food.region == \"West\"]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "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>name</th>\n", " <th>ingredients</th>\n", " <th>diet</th>\n", " <th>prep_time</th>\n", " <th>cook_time</th>\n", " <th>flavor_profile</th>\n", " <th>course</th>\n", " <th>state</th>\n", " <th>region</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>1</th>\n", " <td>Boondi</td>\n", " <td>Gram flour, ghee, sugar</td>\n", " <td>vegetarian</td>\n", " <td>80</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>Ghevar</td>\n", " <td>Flour, ghee, kewra, milk, clarified butter, su...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>30</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>16</th>\n", " <td>Sheera</td>\n", " <td>Semolina, ghee, nuts, milk</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>25</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>19</th>\n", " <td>Sohan papdi</td>\n", " <td>Gram flour, ghee, sugar, milk, cardamom</td>\n", " <td>vegetarian</td>\n", " <td>-1</td>\n", " <td>60</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>39</th>\n", " <td>Chikki</td>\n", " <td>Peanuts, jaggery</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>20</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>217</th>\n", " <td>Khaman</td>\n", " <td>Yogurt, fresh coconut, sesame seeds, semolina,...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>20</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>218</th>\n", " <td>Turiya Patra Vatana sabji</td>\n", " <td>Ridge gourd, baking soda, sugar, grated coconu...</td>\n", " <td>vegetarian</td>\n", " <td>35</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>219</th>\n", " <td>Churma Ladoo</td>\n", " <td>Whole wheat flour, khus khus, sesame seeds, dr...</td>\n", " <td>vegetarian</td>\n", " <td>12</td>\n", " <td>40</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>251</th>\n", " <td>Bebinca</td>\n", " <td>Coconut milk, egg yolks, clarified butter, all...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>60</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Goa</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>254</th>\n", " <td>Pinaca</td>\n", " <td>Brown rice, fennel seeds, grated coconut, blac...</td>\n", " <td>vegetarian</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " <td>sweet</td>\n", " <td>dessert</td>\n", " <td>Goa</td>\n", " <td>West</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "<p>74 rows × 9 columns</p>\n", "</div>" ], "text/plain": [ " name ... region\n", "1 Boondi ... West\n", "3 Ghevar ... West\n", "16 Sheera ... West\n", "19 Sohan papdi ... West\n", "39 Chikki ... West\n", ".. ... ... ...\n", "217 Khaman ... West\n", "218 Turiya Patra Vatana sabji ... West\n", "219 Churma Ladoo ... West\n", "251 Bebinca ... West\n", "254 Pinaca ... West\n", "\n", "[74 rows x 9 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 63 } ] }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 1000 }, "id": "-6demF6QcYWe", "outputId": "61290956-f7aa-457c-ab8e-e92db8e393c0" }, "source": [ "#In fact you wants the recipes from the West which are spicy\n", "indian_food[(indian_food.region == \"West\") & (indian_food.flavor_profile == \"spicy\")]" ], "execution_count": null, "outputs": [ { "output_type": "execute_result", "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>name</th>\n", " <th>ingredients</th>\n", " <th>diet</th>\n", " <th>prep_time</th>\n", " <th>cook_time</th>\n", " <th>flavor_profile</th>\n", " <th>course</th>\n", " <th>state</th>\n", " <th>region</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>83</th>\n", " <td>Daal baati churma</td>\n", " <td>Moong dal, masoor dal, chana dal, wheat flour,...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>90</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>88</th>\n", " <td>Poha</td>\n", " <td>Beaten rice flakes, potato, curry leaves, gree...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>113</th>\n", " <td>Pattor</td>\n", " <td>Arbi ke patte, sesame seeds, gur, bengal gram ...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>165</th>\n", " <td>Amti</td>\n", " <td>Kala masala, arhar dal, curry leaves, mustard ...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>45</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>166</th>\n", " <td>Zunka</td>\n", " <td>Gram flour, mustard, garlic, turmeric, red chilli</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>25</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>167</th>\n", " <td>Kolim Jawla</td>\n", " <td>Baingan, fish, coconut oil, fresh coconut, ginger</td>\n", " <td>non vegetarian</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>168</th>\n", " <td>Saath</td>\n", " <td>Urad dal, potatoes, wheat flour, sooji</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>169</th>\n", " <td>Bajri no rotlo</td>\n", " <td>Wheat flour, pearl millet flour, hot water</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>10</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>172</th>\n", " <td>Bombil fry</td>\n", " <td>Bombay duck, malvani masala, rice flour, bomba...</td>\n", " <td>non vegetarian</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>173</th>\n", " <td>Chakali</td>\n", " <td>Rice flour, sesame, plain flour, turmeric, red...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>174</th>\n", " <td>Chevdo</td>\n", " <td>Citric acid, fry, raisins, sugar, chana daal</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>175</th>\n", " <td>Chorafali</td>\n", " <td>Urad dal, bengal gram flour, dried mango, baki...</td>\n", " <td>vegetarian</td>\n", " <td>5</td>\n", " <td>15</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>177</th>\n", " <td>Daal Dhokli</td>\n", " <td>Whole wheat flour, dal, kokum, gur, bengal gra...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>178</th>\n", " <td>Kutchi dabeli</td>\n", " <td>Pav, aloo, peanut, pomegranate, star anise</td>\n", " <td>vegetarian</td>\n", " <td>30</td>\n", " <td>10</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>181</th>\n", " <td>Dhokla</td>\n", " <td>Rava, coconut, gram flour, mustard, sesame</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>20</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>183</th>\n", " <td>Gatta curry</td>\n", " <td>Yogurt, besan, sauce, garam masala powder, gra...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>20</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Rajasthan</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>185</th>\n", " <td>Ghooghra</td>\n", " <td>Dry fruits, semolina, all purpose flour</td>\n", " <td>vegetarian</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>186</th>\n", " <td>Handwo</td>\n", " <td>Bottle gourd, chana dal, cabbage, urad dal, to...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>188</th>\n", " <td>Jeera Aloo</td>\n", " <td>Green chilies, lemon juice, chili powder, boil...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>191</th>\n", " <td>Khakhra</td>\n", " <td>Whole wheat flour, low fat, bengal gram flour</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>192</th>\n", " <td>Khandvi</td>\n", " <td>Green chili paste, white sesame seeds, gram fl...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>45</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>193</th>\n", " <td>Kombdi vade</td>\n", " <td>Rice flour, urad dal, wheat flour, gram flour,...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>25</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>195</th>\n", " <td>Koshimbir</td>\n", " <td>Cucumber, carrot, tomatoes, cilantro</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>10</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>199</th>\n", " <td>Patra</td>\n", " <td>Arbi ke patte, sesame seeds, gur, bengal gram ...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>200</th>\n", " <td>Pav Bhaji</td>\n", " <td>Pav bhaji masala, gobi, potatoes, green peas, ...</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>201</th>\n", " <td>Puri Bhaji</td>\n", " <td>Aloo, urad dal, mustard, ginger, curry leaves</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>202</th>\n", " <td>Sabudana Khichadi</td>\n", " <td>Raw peanuts, sabudana, lemon, avocado oil, cur...</td>\n", " <td>vegetarian</td>\n", " <td>70</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>203</th>\n", " <td>Sev khamani</td>\n", " <td>Khaman, pomegranate, sev, powdered sugar, garlic</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>204</th>\n", " <td>Sev tameta</td>\n", " <td>Sev, ginger, tomato, sugar</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>205</th>\n", " <td>Namakpara</td>\n", " <td>Wheat flour, baking soda, all purpose flour, b...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>35</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>207</th>\n", " <td>Surnoli</td>\n", " <td>Rice flakes, yogurt, raw rice, jaggery, grated...</td>\n", " <td>vegetarian</td>\n", " <td>60</td>\n", " <td>10</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>208</th>\n", " <td>Thalipeeth</td>\n", " <td>Whole wheat flour, rice flour, pearl millet fl...</td>\n", " <td>vegetarian</td>\n", " <td>25</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>209</th>\n", " <td>Undhiyu</td>\n", " <td>Sweet potato, surti papdi, baby potatoes, valo...</td>\n", " <td>vegetarian</td>\n", " <td>25</td>\n", " <td>60</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>210</th>\n", " <td>Veg Kolhapuri</td>\n", " <td>Gobi, potato, beans, khus khus, coconut</td>\n", " <td>vegetarian</td>\n", " <td>20</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Maharashtra</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>211</th>\n", " <td>Vindaloo</td>\n", " <td>Chicken, coconut oil, wine vinegar, ginger, gr...</td>\n", " <td>non vegetarian</td>\n", " <td>10</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Goa</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>212</th>\n", " <td>Lilva Kachori</td>\n", " <td>Green garlic chutney, fresh green peas, ginger...</td>\n", " <td>vegetarian</td>\n", " <td>30</td>\n", " <td>6</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>213</th>\n", " <td>Mag Dhokli</td>\n", " <td>Moong beans, jaggery, red chillies, oil, salt</td>\n", " <td>vegetarian</td>\n", " <td>-1</td>\n", " <td>-1</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>214</th>\n", " <td>Khichu</td>\n", " <td>Rice flour, sesame seeds, baking soda, peanut oil</td>\n", " <td>vegetarian</td>\n", " <td>5</td>\n", " <td>10</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>215</th>\n", " <td>Thepla</td>\n", " <td>Chickpea flour, methi leaves, jowar flour, whe...</td>\n", " <td>vegetarian</td>\n", " <td>15</td>\n", " <td>30</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>217</th>\n", " <td>Khaman</td>\n", " <td>Yogurt, fresh coconut, sesame seeds, semolina,...</td>\n", " <td>vegetarian</td>\n", " <td>10</td>\n", " <td>20</td>\n", " <td>spicy</td>\n", " <td>snack</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " <tr>\n", " <th>218</th>\n", " <td>Turiya Patra Vatana sabji</td>\n", " <td>Ridge gourd, baking soda, sugar, grated coconu...</td>\n", " <td>vegetarian</td>\n", " <td>35</td>\n", " <td>40</td>\n", " <td>spicy</td>\n", " <td>main course</td>\n", " <td>Gujarat</td>\n", " <td>West</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " name ... region\n", "83 Daal baati churma ... West\n", "88 Poha ... West\n", "113 Pattor ... West\n", "165 Amti ... West\n", "166 Zunka ... West\n", "167 Kolim Jawla ... West\n", "168 Saath ... West\n", "169 Bajri no rotlo ... West\n", "172 Bombil fry ... West\n", "173 Chakali ... West\n", "174 Chevdo ... West\n", "175 Chorafali ... West\n", "177 Daal Dhokli ... West\n", "178 Kutchi dabeli ... West\n", "181 Dhokla ... West\n", "183 Gatta curry ... West\n", "185 Ghooghra ... West\n", "186 Handwo ... West\n", "188 Jeera Aloo ... West\n", "191 Khakhra ... West\n", "192 Khandvi ... West\n", "193 Kombdi vade ... West\n", "195 Koshimbir ... West\n", "199 Patra ... West\n", "200 Pav Bhaji ... West\n", "201 Puri Bhaji ... West\n", "202 Sabudana Khichadi ... West\n", "203 Sev khamani ... West\n", "204 Sev tameta ... West\n", "205 Namakpara ... West\n", "207 Surnoli ... West\n", "208 Thalipeeth ... West\n", "209 Undhiyu ... West\n", "210 Veg Kolhapuri ... West\n", "211 Vindaloo ... West\n", "212 Lilva Kachori ... West\n", "213 Mag Dhokli ... West\n", "214 Khichu ... West\n", "215 Thepla ... West\n", "217 Khaman ... West\n", "218 Turiya Patra Vatana sabji ... West\n", "\n", "[41 rows x 9 columns]" ] }, "metadata": { "tags": [] }, "execution_count": 65 } ] } ] }