-
Notifications
You must be signed in to change notification settings - Fork 0
Ousoka/TP2_Licence2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
{ "cells": [ { "cell_type": "markdown", "id": "6faebaea", "metadata": {}, "source": [ "# PARTICIPANTS" ] }, { "cell_type": "markdown", "id": "0d329af9", "metadata": {}, "source": [ "## Ousmane Ka\n", "\n", "Michel Dieng\n", "\n", "Karlitou Formance Mendy" ] }, { "cell_type": "markdown", "id": "77981292", "metadata": {}, "source": [ "# Exercice 1:" ] }, { "cell_type": "code", "execution_count": 1, "id": "46d62a28", "metadata": {}, "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>Nom</th>\n", " <th>Age</th>\n", " <th>Poids</th>\n", " <th>Taille</th>\n", " <th>Genre</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>Doudou</td>\n", " <td>10</td>\n", " <td>75</td>\n", " <td>1.5</td>\n", " <td>M</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>Amy</td>\n", " <td>15</td>\n", " <td>123</td>\n", " <td>5.0</td>\n", " <td>F</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>Moussa</td>\n", " <td>20</td>\n", " <td>239</td>\n", " <td>6.1</td>\n", " <td>M</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Nom Age Poids Taille Genre\n", "0 Doudou 10 75 1.5 M\n", "1 Amy 15 123 5.0 F\n", "2 Moussa 20 239 6.1 M" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question1\n", "import numpy as np\n", "import pandas as pd\n", "dico={\"Nom\" :[\"Doudou\",\"Amy\",\"Moussa\"],\"Age\" :[10,15,20],\"Poids\" :[75,123,239],\"Taille\" :[1.5,5.0,6.1],\"Genre\" :[\"M\",\"F\",\"M\"]}\n", "df=pd.DataFrame(dico)\n", "df" ] }, { "cell_type": "code", "execution_count": 6, "id": "d0f8e278", "metadata": {}, "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>Vaches</th>\n", " <th>Chevres</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>an 1</th>\n", " <td>12</td>\n", " <td>22</td>\n", " </tr>\n", " <tr>\n", " <th>an 2</th>\n", " <td>20</td>\n", " <td>19</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Vaches Chevres\n", "an 1 12 22\n", "an 2 20 19" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question2\n", "dico1={\"Vaches\" :[12,20],\"Chevres\" :[22,19]}\n", "index_labels=['an 1','an 2',]\n", "df1=pd.DataFrame(dico1,index=index_labels)\n", "df1" ] }, { "cell_type": "code", "execution_count": 8, "id": "b75e9f02", "metadata": {}, "outputs": [], "source": [ "#Question3\n", "df1.to_csv('C:\\\\Users\\\\LENOVO\\\\Desktop\\\\Informatique\\\\07-04-2022\\\\TP2\\\\TP2.csv') " ] }, { "cell_type": "code", "execution_count": 12, "id": "7ace4057", "metadata": {}, "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>Vaches</th>\n", " <th>Chevres</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>an 1</th>\n", " <td>12</td>\n", " <td>22</td>\n", " </tr>\n", " <tr>\n", " <th>an 2</th>\n", " <td>20</td>\n", " <td>19</td>\n", " </tr>\n", " </tbody>\n", "</table>\n", "</div>" ], "text/plain": [ " Vaches Chevres\n", "an 1 12 22\n", "an 2 20 19" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question4\n", "import pandas as pd\n", "df2=pd.read_csv(\"TP2.csv\",index_col=0)\n", "df2" ] }, { "cell_type": "markdown", "id": "f18d53f9", "metadata": {}, "source": [ "# Exercice 2:" ] }, { "cell_type": "code", "execution_count": 1, "id": "e9a24025", "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div><div id=41eb42e6-0a7d-4195-acf2-3c760d4b90fb style=\"display:none; background-color:#9D6CFF; color:white; width:200px; height:30px; padding-left:5px; border-radius:4px; flex-direction:row; justify-content:space-around; align-items:center;\" onmouseover=\"this.style.backgroundColor='#BA9BF8'\" onmouseout=\"this.style.backgroundColor='#9D6CFF'\" onclick=\"window.commands?.execute('create-mitosheet-from-dataframe-output');\">See Full Dataframe in Mito</div> <script> if (window.commands.hasCommand('create-mitosheet-from-dataframe-output')) document.getElementById('41eb42e6-0a7d-4195-acf2-3c760d4b90fb').style.display = 'flex' </script> <table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>country</th>\n", " <th>description</th>\n", " <th>designation</th>\n", " <th>points</th>\n", " <th>price</th>\n", " <th>province</th>\n", " <th>region_1</th>\n", " <th>region_2</th>\n", " <th>taster_name</th>\n", " <th>taster_twitter_handle</th>\n", " <th>title</th>\n", " <th>variety</th>\n", " <th>winery</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>Italy</td>\n", " <td>Aromas include tropical fruit, broom, brimstone and dried herb. The palate isn't overly expressive, offering unripened apple, citrus and dried sage alongside brisk acidity.</td>\n", " <td>Vulkà Bianco</td>\n", " <td>87</td>\n", " <td>NaN</td>\n", " <td>Sicily & Sardinia</td>\n", " <td>Etna</td>\n", " <td>NaN</td>\n", " <td>Kerin O’Keefe</td>\n", " <td>@kerinokeefe</td>\n", " <td>Nicosia 2013 Vulkà Bianco (Etna)</td>\n", " <td>White Blend</td>\n", " <td>Nicosia</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>Portugal</td>\n", " <td>This is ripe and fruity, a wine that is smooth while still structured. Firm tannins are filled out with juicy red berry fruits and freshened with acidity. It's already drinkable, although it will certainly be better from 2016.</td>\n", " <td>Avidagos</td>\n", " <td>87</td>\n", " <td>15.0</td>\n", " <td>Douro</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Quinta dos Avidagos 2011 Avidagos Red (Douro)</td>\n", " <td>Portuguese Red</td>\n", " <td>Quinta dos Avidagos</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>US</td>\n", " <td>Tart and snappy, the flavors of lime flesh and rind dominate. Some green pineapple pokes through, with crisp acidity underscoring the flavors. The wine was all stainless-steel fermented.</td>\n", " <td>NaN</td>\n", " <td>87</td>\n", " <td>14.0</td>\n", " <td>Oregon</td>\n", " <td>Willamette Valley</td>\n", " <td>Willamette Valley</td>\n", " <td>Paul Gregutt</td>\n", " <td>@paulgwine</td>\n", " <td>Rainstorm 2013 Pinot Gris (Willamette Valley)</td>\n", " <td>Pinot Gris</td>\n", " <td>Rainstorm</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>US</td>\n", " <td>Pineapple rind, lemon pith and orange blossom start off the aromas. The palate is a bit more opulent, with notes of honey-drizzled guava and mango giving way to a slightly astringent, semidry finish.</td>\n", " <td>Reserve Late Harvest</td>\n", " <td>87</td>\n", " <td>13.0</td>\n", " <td>Michigan</td>\n", " <td>Lake Michigan Shore</td>\n", " <td>NaN</td>\n", " <td>Alexander Peartree</td>\n", " <td>NaN</td>\n", " <td>St. Julian 2013 Reserve Late Harvest Riesling (Lake Michigan Shore)</td>\n", " <td>Riesling</td>\n", " <td>St. Julian</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>US</td>\n", " <td>Much like the regular bottling from 2012, this comes across as rather rough and tannic, with rustic, earthy, herbal characteristics. Nonetheless, if you think of it as a pleasantly unfussy country wine, it's a good companion to a hearty winter stew.</td>\n", " <td>Vintner's Reserve Wild Child Block</td>\n", " <td>87</td>\n", " <td>65.0</td>\n", " <td>Oregon</td>\n", " <td>Willamette Valley</td>\n", " <td>Willamette Valley</td>\n", " <td>Paul Gregutt</td>\n", " <td>@paulgwine</td>\n", " <td>Sweet Cheeks 2012 Vintner's Reserve Wild Child Block Pinot Noir (Willamette Valley)</td>\n", " <td>Pinot Noir</td>\n", " <td>Sweet Cheeks</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", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>129966</th>\n", " <td>Germany</td>\n", " <td>Notes of honeysuckle and cantaloupe sweeten this deliciously feather-light spätlese. It's intensely juicy, quenching the palate with streams of tart tangerine and grapefruit acidity, yet wraps up with a kiss of honey and peach.</td>\n", " <td>Brauneberger Juffer-Sonnenuhr Spätlese</td>\n", " <td>90</td>\n", " <td>28.0</td>\n", " <td>Mosel</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Anna Lee C. Iijima</td>\n", " <td>NaN</td>\n", " <td>Dr. H. Thanisch (Erben Müller-Burggraef) 2013 Brauneberger Juffer-Sonnenuhr Spätlese Riesling (Mosel)</td>\n", " <td>Riesling</td>\n", " <td>Dr. H. Thanisch (Erben Müller-Burggraef)</td>\n", " </tr>\n", " <tr>\n", " <th>129967</th>\n", " <td>US</td>\n", " <td>Citation is given as much as a decade of bottle age prior to release, which means it is pre-cellared and drinking at its peak. Baked cherry, cocoa and coconut flavors combine gracefully, with soft, secondary fruit compote highlights.</td>\n", " <td>NaN</td>\n", " <td>90</td>\n", " <td>75.0</td>\n", " <td>Oregon</td>\n", " <td>Oregon</td>\n", " <td>Oregon Other</td>\n", " <td>Paul Gregutt</td>\n", " <td>@paulgwine</td>\n", " <td>Citation 2004 Pinot Noir (Oregon)</td>\n", " <td>Pinot Noir</td>\n", " <td>Citation</td>\n", " </tr>\n", " <tr>\n", " <th>129968</th>\n", " <td>France</td>\n", " <td>Well-drained gravel soil gives this wine its crisp and dry character. It is ripe and fruity, although the spice is subdued in favor of a more serious structure. This is a wine to age for a couple of years, so drink from 2017.</td>\n", " <td>Kritt</td>\n", " <td>90</td>\n", " <td>30.0</td>\n", " <td>Alsace</td>\n", " <td>Alsace</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Domaine Gresser 2013 Kritt Gewurztraminer (Alsace)</td>\n", " <td>Gewürztraminer</td>\n", " <td>Domaine Gresser</td>\n", " </tr>\n", " <tr>\n", " <th>129969</th>\n", " <td>France</td>\n", " <td>A dry style of Pinot Gris, this is crisp with some acidity. It also has weight and a solid, powerful core of spice and baked apple flavors. With its structure still developing, the wine needs to age. Drink from 2015.</td>\n", " <td>NaN</td>\n", " <td>90</td>\n", " <td>32.0</td>\n", " <td>Alsace</td>\n", " <td>Alsace</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Domaine Marcel Deiss 2012 Pinot Gris (Alsace)</td>\n", " <td>Pinot Gris</td>\n", " <td>Domaine Marcel Deiss</td>\n", " </tr>\n", " <tr>\n", " <th>129970</th>\n", " <td>France</td>\n", " <td>Big, rich and off-dry, this is powered by intense spiciness and rounded texture. Lychees dominate the fruit profile, giving an opulent feel to the aftertaste. Drink now.</td>\n", " <td>Lieu-dit Harth Cuvée Caroline</td>\n", " <td>90</td>\n", " <td>21.0</td>\n", " <td>Alsace</td>\n", " <td>Alsace</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Domaine Schoffit 2012 Lieu-dit Harth Cuvée Caroline Gewurztraminer (Alsace)</td>\n", " <td>Gewürztraminer</td>\n", " <td>Domaine Schoffit</td>\n", " </tr>\n", " </tbody>\n", "</table></div>" ], "text/plain": [ " country description \\\n", "0 Italy Aromas include tropical fruit, broom, brimston... \n", "1 Portugal This is ripe and fruity, a wine that is smooth... \n", "2 US Tart and snappy, the flavors of lime flesh and... \n", "3 US Pineapple rind, lemon pith and orange blossom ... \n", "4 US Much like the regular bottling from 2012, this... \n", "... ... ... \n", "129966 Germany Notes of honeysuckle and cantaloupe sweeten th... \n", "129967 US Citation is given as much as a decade of bottl... \n", "129968 France Well-drained gravel soil gives this wine its c... \n", "129969 France A dry style of Pinot Gris, this is crisp with ... \n", "129970 France Big, rich and off-dry, this is powered by inte... \n", "\n", " designation points price \\\n", "0 Vulkà Bianco 87 NaN \n", "1 Avidagos 87 15.0 \n", "2 NaN 87 14.0 \n", "3 Reserve Late Harvest 87 13.0 \n", "4 Vintner's Reserve Wild Child Block 87 65.0 \n", "... ... ... ... \n", "129966 Brauneberger Juffer-Sonnenuhr Spätlese 90 28.0 \n", "129967 NaN 90 75.0 \n", "129968 Kritt 90 30.0 \n", "129969 NaN 90 32.0 \n", "129970 Lieu-dit Harth Cuvée Caroline 90 21.0 \n", "\n", " province region_1 region_2 \\\n", "0 Sicily & Sardinia Etna NaN \n", "1 Douro NaN NaN \n", "2 Oregon Willamette Valley Willamette Valley \n", "3 Michigan Lake Michigan Shore NaN \n", "4 Oregon Willamette Valley Willamette Valley \n", "... ... ... ... \n", "129966 Mosel NaN NaN \n", "129967 Oregon Oregon Oregon Other \n", "129968 Alsace Alsace NaN \n", "129969 Alsace Alsace NaN \n", "129970 Alsace Alsace NaN \n", "\n", " taster_name taster_twitter_handle \\\n", "0 Kerin O’Keefe @kerinokeefe \n", "1 Roger Voss @vossroger \n", "2 Paul Gregutt @paulgwine \n", "3 Alexander Peartree NaN \n", "4 Paul Gregutt @paulgwine \n", "... ... ... \n", "129966 Anna Lee C. Iijima NaN \n", "129967 Paul Gregutt @paulgwine \n", "129968 Roger Voss @vossroger \n", "129969 Roger Voss @vossroger \n", "129970 Roger Voss @vossroger \n", "\n", " title variety \\\n", "0 Nicosia 2013 Vulkà Bianco (Etna) White Blend \n", "1 Quinta dos Avidagos 2011 Avidagos Red (Douro) Portuguese Red \n", "2 Rainstorm 2013 Pinot Gris (Willamette Valley) Pinot Gris \n", "3 St. Julian 2013 Reserve Late Harvest Riesling ... Riesling \n", "4 Sweet Cheeks 2012 Vintner's Reserve Wild Child... Pinot Noir \n", "... ... ... \n", "129966 Dr. H. Thanisch (Erben Müller-Burggraef) 2013 ... Riesling \n", "129967 Citation 2004 Pinot Noir (Oregon) Pinot Noir \n", "129968 Domaine Gresser 2013 Kritt Gewurztraminer (Als... Gewürztraminer \n", "129969 Domaine Marcel Deiss 2012 Pinot Gris (Alsace) Pinot Gris \n", "129970 Domaine Schoffit 2012 Lieu-dit Harth Cuvée Car... Gewürztraminer \n", "\n", " winery \n", "0 Nicosia \n", "1 Quinta dos Avidagos \n", "2 Rainstorm \n", "3 St. Julian \n", "4 Sweet Cheeks \n", "... ... \n", "129966 Dr. H. Thanisch (Erben Müller-Burggraef) \n", "129967 Citation \n", "129968 Domaine Gresser \n", "129969 Domaine Marcel Deiss \n", "129970 Domaine Schoffit \n", "\n", "[129971 rows x 13 columns]" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question 1\n", "import pandas as pd\n", "df=pd.read_csv(\"boissons_evaluees.csv\",index_col=0)\n", "df" ] }, { "cell_type": "code", "execution_count": 2, "id": "c41f736d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "count 129971.000000\n", "mean 88.447138\n", "std 3.039730\n", "min 80.000000\n", "25% 86.000000\n", "50% 88.000000\n", "75% 91.000000\n", "max 100.000000\n", "Name: points, dtype: float64" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question2\n", "df.points.describe()" ] }, { "cell_type": "code", "execution_count": 3, "id": "bc988c95", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "La médiane de la colonne points dans le DataFrame boisson est: 88.0\n" ] }, { "data": { "text/plain": [ "88.0" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(\"La médiane de la colonne points dans le DataFrame boisson est:\",88.000000)\n", "df.points.median()" ] }, { "cell_type": "code", "execution_count": 4, "id": "312d474d", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "La médiane de la colonne points dans le DataFrame boisson est: 88\n" ] } ], "source": [ "#Autre Méthode\n", "import statistics as sta\n", "X=df.points\n", "print(\"La médiane de la colonne points dans le DataFrame boisson est:\",sta.median(X))" ] }, { "cell_type": "code", "execution_count": 5, "id": "007236e1", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['Italy', 'Portugal', 'US', 'Spain', 'France', 'Germany',\n", " 'Argentina', 'Chile', 'Australia', 'Austria', 'South Africa',\n", " 'New Zealand', 'Israel', 'Hungary', 'Greece', 'Romania', 'Mexico',\n", " 'Canada', nan, 'Turkey', 'Czech Republic', 'Slovenia',\n", " 'Luxembourg', 'Croatia', 'Georgia', 'Uruguay', 'England',\n", " 'Lebanon', 'Serbia', 'Brazil', 'Moldova', 'Morocco', 'Peru',\n", " 'India', 'Bulgaria', 'Cyprus', 'Armenia', 'Switzerland',\n", " 'Bosnia and Herzegovina', 'Ukraine', 'Slovakia', 'Macedonia',\n", " 'China', 'Egypt'], dtype=object)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question3\n", "df.country.unique()" ] }, { "cell_type": "code", "execution_count": 6, "id": "50c7fb92", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "US 54504\n", "France 22093\n", "Italy 19540\n", "Spain 6645\n", "Portugal 5691\n", "Chile 4472\n", "Argentina 3800\n", "Austria 3345\n", "Australia 2329\n", "Germany 2165\n", "New Zealand 1419\n", "South Africa 1401\n", "Israel 505\n", "Greece 466\n", "Canada 257\n", "Hungary 146\n", "Bulgaria 141\n", "Romania 120\n", "Uruguay 109\n", "Turkey 90\n", "Slovenia 87\n", "Georgia 86\n", "England 74\n", "Croatia 73\n", "Mexico 70\n", "Moldova 59\n", "Brazil 52\n", "Lebanon 35\n", "Morocco 28\n", "Peru 16\n", "Ukraine 14\n", "Czech Republic 12\n", "Serbia 12\n", "Macedonia 12\n", "Cyprus 11\n", "India 9\n", "Switzerland 7\n", "Luxembourg 6\n", "Bosnia and Herzegovina 2\n", "Armenia 2\n", "China 1\n", "Slovakia 1\n", "Egypt 1\n", "Name: country, dtype: int64" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question4\n", "#Frequency\n", "df.country.value_counts()" ] }, { "cell_type": "code", "execution_count": 7, "id": "31259cc9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "country\n", "Argentina 18\n", "Armenia 2\n", "Australia 21\n", "Austria 17\n", "Bosnia and Herzegovina 2\n", "Brazil 10\n", "Bulgaria 11\n", "Canada 13\n", "Chile 16\n", "China 1\n", "Croatia 11\n", "Cyprus 4\n", "Czech Republic 5\n", "Egypt 1\n", "England 7\n", "France 21\n", "Georgia 10\n", "Germany 18\n", "Greece 12\n", "Hungary 16\n", "India 6\n", "Israel 15\n", "Italy 21\n", "Lebanon 10\n", "Luxembourg 3\n", "Macedonia 6\n", "Mexico 13\n", "Moldova 10\n", "Morocco 8\n", "New Zealand 16\n", "Peru 7\n", "Portugal 21\n", "Romania 10\n", "Serbia 4\n", "Slovakia 1\n", "Slovenia 11\n", "South Africa 14\n", "Spain 19\n", "Switzerland 3\n", "Turkey 9\n", "US 21\n", "Ukraine 6\n", "Uruguay 13\n", "dtype: int64" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Serie de boisson par pays\n", "from pandas import Series\n", "boisson_pays=df.groupby(\"country\").points.unique()\n", "#boisson_pays[boisson_pays.index[0]]\n", "#boisson_pays.index\n", "#boisson_pays\n", "#boisson_pays[0]\n", "critique=[]\n", "for i in range(len(boisson_pays.index)):\n", " critique.append(len(boisson_pays[i]))\n", "#critique=np.array(critique)\n", "serie_boisson=Series(critique, index=boisson_pays.index)\n", "serie_boisson" ] }, { "cell_type": "code", "execution_count": 8, "id": "5560b0fe", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ nan, -20.36338913, -21.36338913, ..., -5.36338913,\n", " -3.36338913, -14.36338913])" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question5\n", "import numpy as np\n", "prix_centre=df['price'].values-np.nanmean(df['price'].values)\n", "prix_centre\n", "#ctr+/ to comment a hole block of code" ] }, { "cell_type": "code", "execution_count": 9, "id": "5232da86", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ nan, -20.36338913, -21.36338913, ..., -5.36338913,\n", " -3.36338913, -14.36338913])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Autre methode\n", "q=df.price\n", "prix_centre=np.nanmean(df.price)\n", "p1=[]\n", "for i in range(len(q)):\n", " o=q[i]-prix_centre\n", " p1.append(o)\n", "p1=np.array(p1)\n", "p1" ] }, { "cell_type": "code", "execution_count": 11, "id": "cb0db92c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['Bandit NV Merlot (California)', 'Cramele Recas 2011 UnWineD Pinot Grigio (Viile Timisului)'] \n", " sont les meilleures boissons avec un rapport qualité/prix égale à 21.5\n" ] } ], "source": [ "#Question6\n", "import numpy as np\n", "boisson_negociee=df.points/df.price\n", "idx_meilleure_boisson=np.where(boisson_negociee==boisson_negociee.max())\n", "meilleure_boisson=[]\n", "for i in range(len(idx_meilleure_boisson[0])):\n", " meilleure_boisson.append(df.title[idx_meilleure_boisson[0][i]])\n", "print(meilleure_boisson,\"\\n sont les meilleures boissons avec un rapport qualité/prix égale à\",boisson_negociee.max())" ] }, { "cell_type": "code", "execution_count": 12, "id": "9e5008c7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "<div><div id=2d6d922f-ffc8-41e4-8caf-f95721ab2e29 style=\"display:none; background-color:#9D6CFF; color:white; width:200px; height:30px; padding-left:5px; border-radius:4px; flex-direction:row; justify-content:space-around; align-items:center;\" onmouseover=\"this.style.backgroundColor='#BA9BF8'\" onmouseout=\"this.style.backgroundColor='#9D6CFF'\" onclick=\"window.commands?.execute('create-mitosheet-from-dataframe-output');\">See Full Dataframe in Mito</div> <script> if (window.commands.hasCommand('create-mitosheet-from-dataframe-output')) document.getElementById('2d6d922f-ffc8-41e4-8caf-f95721ab2e29').style.display = 'flex' </script> <table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>country</th>\n", " <th>description</th>\n", " <th>designation</th>\n", " <th>points</th>\n", " <th>price</th>\n", " <th>province</th>\n", " <th>region_1</th>\n", " <th>region_2</th>\n", " <th>taster_name</th>\n", " <th>taster_twitter_handle</th>\n", " <th>title</th>\n", " <th>variety</th>\n", " <th>winery</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>64590</th>\n", " <td>US</td>\n", " <td>There's a lot going on in this Merlot, which is likeable now for its rich blackberry, cherry, cranberry, cola and spice flavors. It's dry and balanced.</td>\n", " <td>NaN</td>\n", " <td>86</td>\n", " <td>4.0</td>\n", " <td>California</td>\n", " <td>California</td>\n", " <td>California Other</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Bandit NV Merlot (California)</td>\n", " <td>Merlot</td>\n", " <td>Bandit</td>\n", " </tr>\n", " <tr>\n", " <th>126096</th>\n", " <td>Romania</td>\n", " <td>Notes of sun-dried hay and green flower highlight the nose and palate of this fresh, easy-quaffing wine. Concentrated tangerine and pineapple flavors are brisk and tasty.</td>\n", " <td>UnWineD</td>\n", " <td>86</td>\n", " <td>4.0</td>\n", " <td>Viile Timisului</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Anna Lee C. Iijima</td>\n", " <td>NaN</td>\n", " <td>Cramele Recas 2011 UnWineD Pinot Grigio (Viile Timisului)</td>\n", " <td>Pinot Grigio</td>\n", " <td>Cramele Recas</td>\n", " </tr>\n", " </tbody>\n", "</table></div>" ], "text/plain": [ " country description \\\n", "64590 US There's a lot going on in this Merlot, which i... \n", "126096 Romania Notes of sun-dried hay and green flower highli... \n", "\n", " designation points price province region_1 \\\n", "64590 NaN 86 4.0 California California \n", "126096 UnWineD 86 4.0 Viile Timisului NaN \n", "\n", " region_2 taster_name taster_twitter_handle \\\n", "64590 California Other NaN NaN \n", "126096 NaN Anna Lee C. Iijima NaN \n", "\n", " title variety \\\n", "64590 Bandit NV Merlot (California) Merlot \n", "126096 Cramele Recas 2011 UnWineD Pinot Grigio (Viile... Pinot Grigio \n", "\n", " winery \n", "64590 Bandit \n", "126096 Cramele Recas " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Autre methode\n", "df.loc[idx_meilleure_boisson[0]]" ] }, { "cell_type": "markdown", "id": "d31b1a72", "metadata": {}, "source": [ "# Exercice 3:" ] }, { "cell_type": "code", "execution_count": 13, "id": "b2265d4d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Int64Index([88, 87, 90, 86, 89, 91], dtype='int64')" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question1\n", "bf=df.points.value_counts()\n", "bf.index[0:6] #echantillon\n", "# bf" ] }, { "cell_type": "code", "execution_count": 14, "id": "d3095ff0", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "taster_twitter_handle\n", "@AnneInVino 3685\n", "@JoeCz 5147\n", "@bkfiona 27\n", "@gordone_cellars 4177\n", "@kerinokeefe 10776\n", "@laurbuzz 1835\n", "@mattkettmann 6332\n", "@paulgwine 9532\n", "@suskostrzewa 1085\n", "@vboone 9537\n", "@vossroger 25514\n", "@wawinereport 4966\n", "@wineschach 15134\n", "@winewchristina 6\n", "@worldwineguys 1005\n", "Name: points, dtype: int64" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.groupby(\"taster_twitter_handle\").points.count()" ] }, { "cell_type": "code", "execution_count": 15, "id": "7e8a757f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "taster_twitter_handle\n", "@AnneInVino 17\n", "@JoeCz 21\n", "@bkfiona 7\n", "@gordone_cellars 18\n", "@kerinokeefe 21\n", "@laurbuzz 15\n", "@mattkettmann 17\n", "@paulgwine 21\n", "@suskostrzewa 15\n", "@vboone 20\n", "@vossroger 21\n", "@wawinereport 18\n", "@wineschach 19\n", "@winewchristina 4\n", "@worldwineguys 16\n", "dtype: int64" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pandas import Series\n", "twitter_critique=df.groupby(\"taster_twitter_handle\").points.unique()\n", "critique_twit=[]\n", "for i in range(len(twitter_critique.index)):\n", " critique_twit.append(len(twitter_critique[i]))\n", "serie_twit_critique=Series(critique_twit,index=twitter_critique.index)\n", "serie_twit_critique" ] }, { "cell_type": "code", "execution_count": 16, "id": "91ea2afa", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name your price: 4\n", "\n", "The best drinks are:\n" ] }, { "data": { "text/html": [ "<div><div id=be3c254c-3151-46c0-9551-787f5e1c5504 style=\"display:none; background-color:#9D6CFF; color:white; width:200px; height:30px; padding-left:5px; border-radius:4px; flex-direction:row; justify-content:space-around; align-items:center;\" onmouseover=\"this.style.backgroundColor='#BA9BF8'\" onmouseout=\"this.style.backgroundColor='#9D6CFF'\" onclick=\"window.commands?.execute('create-mitosheet-from-dataframe-output');\">See Full Dataframe in Mito</div> <script> if (window.commands.hasCommand('create-mitosheet-from-dataframe-output')) document.getElementById('be3c254c-3151-46c0-9551-787f5e1c5504').style.display = 'flex' </script> <table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>country</th>\n", " <th>description</th>\n", " <th>Best</th>\n", " <th>designation</th>\n", " <th>points</th>\n", " <th>price</th>\n", " <th>province</th>\n", " <th>region_1</th>\n", " <th>region_2</th>\n", " <th>taster_name</th>\n", " <th>taster_twitter_handle</th>\n", " <th>title</th>\n", " <th>variety</th>\n", " <th>winery</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>64590</th>\n", " <td>US</td>\n", " <td>There's a lot going on in this Merlot, which is likeable now for its rich blackberry, cherry, cranberry, cola and spice flavors. It's dry and balanced.</td>\n", " <td>21.5</td>\n", " <td>NaN</td>\n", " <td>86</td>\n", " <td>4.0</td>\n", " <td>California</td>\n", " <td>California</td>\n", " <td>California Other</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Bandit NV Merlot (California)</td>\n", " <td>Merlot</td>\n", " <td>Bandit</td>\n", " </tr>\n", " <tr>\n", " <th>126096</th>\n", " <td>Romania</td>\n", " <td>Notes of sun-dried hay and green flower highlight the nose and palate of this fresh, easy-quaffing wine. Concentrated tangerine and pineapple flavors are brisk and tasty.</td>\n", " <td>21.5</td>\n", " <td>UnWineD</td>\n", " <td>86</td>\n", " <td>4.0</td>\n", " <td>Viile Timisului</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Anna Lee C. Iijima</td>\n", " <td>NaN</td>\n", " <td>Cramele Recas 2011 UnWineD Pinot Grigio (Viile Timisului)</td>\n", " <td>Pinot Grigio</td>\n", " <td>Cramele Recas</td>\n", " </tr>\n", " </tbody>\n", "</table></div>" ], "text/plain": [ " country description Best \\\n", "64590 US There's a lot going on in this Merlot, which i... 21.5 \n", "126096 Romania Notes of sun-dried hay and green flower highli... 21.5 \n", "\n", " designation points price province region_1 \\\n", "64590 NaN 86 4.0 California California \n", "126096 UnWineD 86 4.0 Viile Timisului NaN \n", "\n", " region_2 taster_name taster_twitter_handle \\\n", "64590 California Other NaN NaN \n", "126096 NaN Anna Lee C. Iijima NaN \n", "\n", " title variety \\\n", "64590 Bandit NV Merlot (California) Merlot \n", "126096 Cramele Recas 2011 UnWineD Pinot Grigio (Viile... Pinot Grigio \n", "\n", " winery \n", "64590 Bandit \n", "126096 Cramele Recas " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question2\n", "import numpy as np\n", "while True:\n", " try:\n", " sum_entry=int(input(\"Name your price: \"))\n", " assert sum_entry>=df.price.min()\n", " break\n", " except ValueError:\n", " print(\"Wrong Entry\")\n", " except AssertionError:\n", " print(\"Your entry should be greater than\",df.price.min(),\"!\")\n", "k=df.loc[df.loc[:,\"price\"]<=sum_entry]\n", "best=k.points/k.price\n", "k.insert(2,\"Best\",best,allow_duplicates=False)\n", "best_drink=k.loc[k.loc[:,\"Best\"]==np.nanmax(best)]\n", "print(\"\\nThe best drinks are:\")\n", "best_drink" ] }, { "cell_type": "code", "execution_count": 17, "id": "5c64bc0c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Max price for every variety:\n", " variety\n", "Abouriou 75.0\n", "Agiorgitiko 66.0\n", "Aglianico 180.0\n", "Aidani 27.0\n", "Airen 10.0\n", " ... \n", "Zinfandel 100.0\n", "Zlahtina 16.0\n", "Zweigelt 70.0\n", "Çalkarası 19.0\n", "Žilavka 15.0\n", "Name: price, Length: 707, dtype: float64 \n", "\n", "************************************************\n", "Min price for every variety:\n", " variety\n", "Abouriou 15.0\n", "Agiorgitiko 10.0\n", "Aglianico 6.0\n", "Aidani 27.0\n", "Airen 8.0\n", " ... \n", "Zinfandel 5.0\n", "Zlahtina 13.0\n", "Zweigelt 9.0\n", "Çalkarası 19.0\n", "Žilavka 15.0\n", "Name: price, Length: 707, dtype: float64\n" ] } ], "source": [ "#Question3\n", "max_price=df.groupby(\"variety\").price.max()\n", "min_price=df.groupby(\"variety\").price.min()\n", "print(\"Max price for every variety:\\n\",max_price,\"\\n\")\n", "print(\"************************************************\")\n", "print(\"Min price for every variety:\\n\",min_price)" ] }, { "cell_type": "code", "execution_count": 18, "id": "6062e662", "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "<div><div id=dc6782b5-3e7b-486a-b7da-3a1d6323626f style=\"display:none; background-color:#9D6CFF; color:white; width:200px; height:30px; padding-left:5px; border-radius:4px; flex-direction:row; justify-content:space-around; align-items:center;\" onmouseover=\"this.style.backgroundColor='#BA9BF8'\" onmouseout=\"this.style.backgroundColor='#9D6CFF'\" onclick=\"window.commands?.execute('create-mitosheet-from-dataframe-output');\">See Full Dataframe in Mito</div> <script> if (window.commands.hasCommand('create-mitosheet-from-dataframe-output')) document.getElementById('dc6782b5-3e7b-486a-b7da-3a1d6323626f').style.display = 'flex' </script> <table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>Max</th>\n", " <th>Min</th>\n", " </tr>\n", " <tr>\n", " <th>variety</th>\n", " <th></th>\n", " <th></th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>Abouriou</th>\n", " <td>75.0</td>\n", " <td>15.0</td>\n", " </tr>\n", " <tr>\n", " <th>Agiorgitiko</th>\n", " <td>66.0</td>\n", " <td>10.0</td>\n", " </tr>\n", " <tr>\n", " <th>Aglianico</th>\n", " <td>180.0</td>\n", " <td>6.0</td>\n", " </tr>\n", " <tr>\n", " <th>Aidani</th>\n", " <td>27.0</td>\n", " <td>27.0</td>\n", " </tr>\n", " <tr>\n", " <th>Airen</th>\n", " <td>10.0</td>\n", " <td>8.0</td>\n", " </tr>\n", " <tr>\n", " <th>...</th>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>Zinfandel</th>\n", " <td>100.0</td>\n", " <td>5.0</td>\n", " </tr>\n", " <tr>\n", " <th>Zlahtina</th>\n", " <td>16.0</td>\n", " <td>13.0</td>\n", " </tr>\n", " <tr>\n", " <th>Zweigelt</th>\n", " <td>70.0</td>\n", " <td>9.0</td>\n", " </tr>\n", " <tr>\n", " <th>Çalkarası</th>\n", " <td>19.0</td>\n", " <td>19.0</td>\n", " </tr>\n", " <tr>\n", " <th>Žilavka</th>\n", " <td>15.0</td>\n", " <td>15.0</td>\n", " </tr>\n", " </tbody>\n", "</table></div>" ], "text/plain": [ " Max Min\n", "variety \n", "Abouriou 75.0 15.0\n", "Agiorgitiko 66.0 10.0\n", "Aglianico 180.0 6.0\n", "Aidani 27.0 27.0\n", "Airen 10.0 8.0\n", "... ... ...\n", "Zinfandel 100.0 5.0\n", "Zlahtina 16.0 13.0\n", "Zweigelt 70.0 9.0\n", "Çalkarası 19.0 19.0\n", "Žilavka 15.0 15.0\n", "\n", "[707 rows x 2 columns]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mprice=pd.DataFrame({\"Max\":max_price,\"Min\":min_price})\n", "mprice" ] }, { "cell_type": "code", "execution_count": 19, "id": "fe1ab010", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "taster_name\n", "Alexander Peartree 85.855422\n", "Anna Lee C. Iijima 88.415629\n", "Anne Krebiehl MW 90.562551\n", "Carrie Dykes 86.395683\n", "Christina Pickard 87.833333\n", "Fiona Adams 86.888889\n", "Jeff Jenssen 88.319756\n", "Jim Gordon 88.626287\n", "Joe Czerwinski 88.536235\n", "Kerin O’Keefe 88.867947\n", "Lauren Buzzeo 87.739510\n", "Matt Kettmann 90.008686\n", "Michael Schachner 86.907493\n", "Mike DeSimone 89.101167\n", "Paul Gregutt 89.082564\n", "Roger Voss 88.708003\n", "Sean P. Sullivan 88.755739\n", "Susan Kostrzewa 86.609217\n", "Virginie Boone 89.213379\n", "Name: points, dtype: float64" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question4\n", "meanpoints=df.groupby(\"taster_name\").points.mean()\n", "meanpoints" ] }, { "cell_type": "code", "execution_count": 20, "id": "0800a745", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dtype('int64')" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#Question5\n", "df.points.dtypes" ] }, { "cell_type": "code", "execution_count": 21, "id": "306e46ae", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "From 129971 notices, there are 8996 missing a price tag.\n" ] } ], "source": [ "#Question6\n", "not_missing_price=df[pd.isnull(df.price)]\n", "print(\"From\",len(df),\"notices, there are \",len(not_missing_price.price),\"missing a price tag.\")" ] }, { "cell_type": "code", "execution_count": 22, "id": "ca32ea10", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "From 129971 notices, there are 8996 missing a price tag.\n" ] } ], "source": [ "#Another method\n", "Not_missing_price=df[pd.notnull(df.price)]\n", "print(\"From\",len(df),\"notices, there are \",len(df.price)-len(Not_missing_price.price),\"missing a price tag.\")" ] }, { "cell_type": "markdown", "id": "5efdc9f0", "metadata": {}, "source": [ "# BROUILLON et REMARQUES" ] }, { "cell_type": "code", "execution_count": 7, "id": "1d1821f0", "metadata": {}, "outputs": [], "source": [ "#import mitosheet\n", "#mitosheet.sheet()\n", "#upload files while typing a code\n", "#pip install mitoinstaller" ] }, { "cell_type": "code", "execution_count": 8, "id": "702fe590", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\LENOVO\\anaconda3\\lib\\site-packages\\pandas\\core\\indexing.py:1637: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " self._setitem_single_block(indexer, value, name)\n" ] }, { "data": { "text/html": [ "<div><div id=880b0467-688a-4f60-81f3-d68b4f29d6b4 style=\"display:none; background-color:#9D6CFF; color:white; width:200px; height:30px; padding-left:5px; border-radius:4px; flex-direction:row; justify-content:space-around; align-items:center;\" onmouseover=\"this.style.backgroundColor='#BA9BF8'\" onmouseout=\"this.style.backgroundColor='#9D6CFF'\" onclick=\"window.commands?.execute('create-mitosheet-from-dataframe-output');\">See Full Dataframe in Mito</div> <script> if (window.commands.hasCommand('create-mitosheet-from-dataframe-output')) document.getElementById('880b0467-688a-4f60-81f3-d68b4f29d6b4').style.display = 'flex' </script> <table border=\"1\" class=\"dataframe\">\n", " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", " <th>country</th>\n", " <th>description</th>\n", " <th>designation</th>\n", " <th>points</th>\n", " <th>price</th>\n", " <th>province</th>\n", " <th>region_1</th>\n", " <th>region_2</th>\n", " <th>taster_name</th>\n", " <th>taster_twitter_handle</th>\n", " <th>title</th>\n", " <th>variety</th>\n", " <th>winery</th>\n", " </tr>\n", " </thead>\n", " <tbody>\n", " <tr>\n", " <th>0</th>\n", " <td>Italy</td>\n", " <td>Aromas include tropical fruit, broom, brimstone and dried herb. The palate isn't overly expressive, offering unripened apple, citrus and dried sage alongside brisk acidity.</td>\n", " <td>Vulkà Bianco</td>\n", " <td>87</td>\n", " <td>NaN</td>\n", " <td>Sicily & Sardinia</td>\n", " <td>Etna</td>\n", " <td>NaN</td>\n", " <td>Kerin O’Keefe</td>\n", " <td>@kerinokeefe</td>\n", " <td>Nicosia 2013 Vulkà Bianco (Etna)</td>\n", " <td>White Blend</td>\n", " <td>Nicosia</td>\n", " </tr>\n", " <tr>\n", " <th>1</th>\n", " <td>Portugal</td>\n", " <td>This is ripe and fruity, a wine that is smooth while still structured. Firm tannins are filled out with juicy red berry fruits and freshened with acidity. It's already drinkable, although it will certainly be better from 2016.</td>\n", " <td>Avidagos</td>\n", " <td>87</td>\n", " <td>15.0</td>\n", " <td>Douro</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Quinta dos Avidagos 2011 Avidagos Red (Douro)</td>\n", " <td>Portuguese Red</td>\n", " <td>Quinta dos Avidagos</td>\n", " </tr>\n", " <tr>\n", " <th>2</th>\n", " <td>US</td>\n", " <td>Tart and snappy, the flavors of lime flesh and rind dominate. Some green pineapple pokes through, with crisp acidity underscoring the flavors. The wine was all stainless-steel fermented.</td>\n", " <td>NaN</td>\n", " <td>87</td>\n", " <td>14.0</td>\n", " <td>Oregon</td>\n", " <td>Willamette Valley</td>\n", " <td>Willamette Valley</td>\n", " <td>Paul Gregutt</td>\n", " <td>@paulgwine</td>\n", " <td>Rainstorm 2013 Pinot Gris (Willamette Valley)</td>\n", " <td>Pinot Gris</td>\n", " <td>Rainstorm</td>\n", " </tr>\n", " <tr>\n", " <th>3</th>\n", " <td>US</td>\n", " <td>Pineapple rind, lemon pith and orange blossom start off the aromas. The palate is a bit more opulent, with notes of honey-drizzled guava and mango giving way to a slightly astringent, semidry finish.</td>\n", " <td>Reserve Late Harvest</td>\n", " <td>87</td>\n", " <td>13.0</td>\n", " <td>Michigan</td>\n", " <td>Lake Michigan Shore</td>\n", " <td>NaN</td>\n", " <td>Alexander Peartree</td>\n", " <td>NaN</td>\n", " <td>St. Julian 2013 Reserve Late Harvest Riesling (Lake Michigan Shore)</td>\n", " <td>Riesling</td>\n", " <td>St. Julian</td>\n", " </tr>\n", " <tr>\n", " <th>4</th>\n", " <td>US</td>\n", " <td>Much like the regular bottling from 2012, this comes across as rather rough and tannic, with rustic, earthy, herbal characteristics. Nonetheless, if you think of it as a pleasantly unfussy country wine, it's a good companion to a hearty winter stew.</td>\n", " <td>Vintner's Reserve Wild Child Block</td>\n", " <td>87</td>\n", " <td>65.0</td>\n", " <td>Oregon</td>\n", " <td>Willamette Valley</td>\n", " <td>Willamette Valley</td>\n", " <td>Paul Gregutt</td>\n", " <td>@paulgwine</td>\n", " <td>Sweet Cheeks 2012 Vintner's Reserve Wild Child Block Pinot Noir (Willamette Valley)</td>\n", " <td>Pinot Noir</td>\n", " <td>Sweet Cheeks</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", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>129966</th>\n", " <td>Germany</td>\n", " <td>Notes of honeysuckle and cantaloupe sweeten this deliciously feather-light spätlese. It's intensely juicy, quenching the palate with streams of tart tangerine and grapefruit acidity, yet wraps up with a kiss of honey and peach.</td>\n", " <td>Brauneberger Juffer-Sonnenuhr Spätlese</td>\n", " <td>90</td>\n", " <td>28.0</td>\n", " <td>Mosel</td>\n", " <td>NaN</td>\n", " <td>NaN</td>\n", " <td>Anna Lee C. Iijima</td>\n", " <td>NaN</td>\n", " <td>Dr. H. Thanisch (Erben Müller-Burggraef) 2013 Brauneberger Juffer-Sonnenuhr Spätlese Riesling (Mosel)</td>\n", " <td>Riesling</td>\n", " <td>Dr. H. Thanisch (Erben Müller-Burggraef)</td>\n", " </tr>\n", " <tr>\n", " <th>129967</th>\n", " <td>US</td>\n", " <td>Citation is given as much as a decade of bottle age prior to release, which means it is pre-cellared and drinking at its peak. Baked cherry, cocoa and coconut flavors combine gracefully, with soft, secondary fruit compote highlights.</td>\n", " <td>NaN</td>\n", " <td>90</td>\n", " <td>75.0</td>\n", " <td>Oregon</td>\n", " <td>Oregon</td>\n", " <td>Oregon Other</td>\n", " <td>Paul Gregutt</td>\n", " <td>@paulgwine</td>\n", " <td>Citation 2004 Pinot Noir (Oregon)</td>\n", " <td>Pinot Noir</td>\n", " <td>Citation</td>\n", " </tr>\n", " <tr>\n", " <th>129968</th>\n", " <td>France</td>\n", " <td>Well-drained gravel soil gives this wine its crisp and dry character. It is ripe and fruity, although the spice is subdued in favor of a more serious structure. This is a wine to age for a couple of years, so drink from 2017.</td>\n", " <td>Kritt</td>\n", " <td>90</td>\n", " <td>30.0</td>\n", " <td>Alsace</td>\n", " <td>Alsace</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Domaine Gresser 2013 Kritt Gewurztraminer (Alsace)</td>\n", " <td>Gewürztraminer</td>\n", " <td>Domaine Gresser</td>\n", " </tr>\n", " <tr>\n", " <th>129969</th>\n", " <td>France</td>\n", " <td>A dry style of Pinot Gris, this is crisp with some acidity. It also has weight and a solid, powerful core of spice and baked apple flavors. With its structure still developing, the wine needs to age. Drink from 2015.</td>\n", " <td>NaN</td>\n", " <td>90</td>\n", " <td>32.0</td>\n", " <td>Alsace</td>\n", " <td>Alsace</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Domaine Marcel Deiss 2012 Pinot Gris (Alsace)</td>\n", " <td>Pinot Gris</td>\n", " <td>Domaine Marcel Deiss</td>\n", " </tr>\n", " <tr>\n", " <th>129970</th>\n", " <td>France</td>\n", " <td>Big, rich and off-dry, this is powered by intense spiciness and rounded texture. Lychees dominate the fruit profile, giving an opulent feel to the aftertaste. Drink now.</td>\n", " <td>Lieu-dit Harth Cuvée Caroline</td>\n", " <td>90</td>\n", " <td>21.0</td>\n", " <td>Alsace</td>\n", " <td>Alsace</td>\n", " <td>NaN</td>\n", " <td>Roger Voss</td>\n", " <td>@vossroger</td>\n", " <td>Domaine Schoffit 2012 Lieu-dit Harth Cuvée Caroline Gewurztraminer (Alsace)</td>\n", " <td>Gewürztraminer</td>\n", " <td>Domaine Schoffit</td>\n", " </tr>\n", " </tbody>\n", "</table></div>" ], "text/plain": [ " country description \\\n", "0 Italy Aromas include tropical fruit, broom, brimston... \n", "1 Portugal This is ripe and fruity, a wine that is smooth... \n", "2 US Tart and snappy, the flavors of lime flesh and... \n", "3 US Pineapple rind, lemon pith and orange blossom ... \n", "4 US Much like the regular bottling from 2012, this... \n", "... ... ... \n", "129966 Germany Notes of honeysuckle and cantaloupe sweeten th... \n", "129967 US Citation is given as much as a decade of bottl... \n", "129968 France Well-drained gravel soil gives this wine its c... \n", "129969 France A dry style of Pinot Gris, this is crisp with ... \n", "129970 France Big, rich and off-dry, this is powered by inte... \n", "\n", " designation points price \\\n", "0 Vulkà Bianco 87 NaN \n", "1 Avidagos 87 15.0 \n", "2 NaN 87 14.0 \n", "3 Reserve Late Harvest 87 13.0 \n", "4 Vintner's Reserve Wild Child Block 87 65.0 \n", "... ... ... ... \n", "129966 Brauneberger Juffer-Sonnenuhr Spätlese 90 28.0 \n", "129967 NaN 90 75.0 \n", "129968 Kritt 90 30.0 \n", "129969 NaN 90 32.0 \n", "129970 Lieu-dit Harth Cuvée Caroline 90 21.0 \n", "\n", " province region_1 region_2 \\\n", "0 Sicily & Sardinia Etna NaN \n", "1 Douro NaN NaN \n", "2 Oregon Willamette Valley Willamette Valley \n", "3 Michigan Lake Michigan Shore NaN \n", "4 Oregon Willamette Valley Willamette Valley \n", "... ... ... ... \n", "129966 Mosel NaN NaN \n", "129967 Oregon Oregon Oregon Other \n", "129968 Alsace Alsace NaN \n", "129969 Alsace Alsace NaN \n", "129970 Alsace Alsace NaN \n", "\n", " taster_name taster_twitter_handle \\\n", "0 Kerin O’Keefe @kerinokeefe \n", "1 Roger Voss @vossroger \n", "2 Paul Gregutt @paulgwine \n", "3 Alexander Peartree NaN \n", "4 Paul Gregutt @paulgwine \n", "... ... ... \n", "129966 Anna Lee C. Iijima NaN \n", "129967 Paul Gregutt @paulgwine \n", "129968 Roger Voss @vossroger \n", "129969 Roger Voss @vossroger \n", "129970 Roger Voss @vossroger \n", "\n", " title variety \\\n", "0 Nicosia 2013 Vulkà Bianco (Etna) White Blend \n", "1 Quinta dos Avidagos 2011 Avidagos Red (Douro) Portuguese Red \n", "2 Rainstorm 2013 Pinot Gris (Willamette Valley) Pinot Gris \n", "3 St. Julian 2013 Reserve Late Harvest Riesling ... Riesling \n", "4 Sweet Cheeks 2012 Vintner's Reserve Wild Child... Pinot Noir \n", "... ... ... \n", "129966 Dr. H. Thanisch (Erben Müller-Burggraef) 2013 ... Riesling \n", "129967 Citation 2004 Pinot Noir (Oregon) Pinot Noir \n", "129968 Domaine Gresser 2013 Kritt Gewurztraminer (Als... Gewürztraminer \n", "129969 Domaine Marcel Deiss 2012 Pinot Gris (Alsace) Pinot Gris \n", "129970 Domaine Schoffit 2012 Lieu-dit Harth Cuvée Car... Gewürztraminer \n", "\n", " winery \n", "0 Nicosia \n", "1 Quinta dos Avidagos \n", "2 Rainstorm \n", "3 St. Julian \n", "4 Sweet Cheeks \n", "... ... \n", "129966 Dr. H. Thanisch (Erben Müller-Burggraef) \n", "129967 Citation \n", "129968 Domaine Gresser \n", "129969 Domaine Marcel Deiss \n", "129970 Domaine Schoffit \n", "\n", "[129971 rows x 13 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1=df\n", "df1['price'].loc[64590]=20\n", "df1" ] }, { "cell_type": "code", "execution_count": 31, "id": "d8cf9688", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "20.0" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df['price'].iloc[64590]=20" ] }, { "cell_type": "code", "execution_count": null, "id": "b4207645", "metadata": {}, "outputs": [], "source": [ "#Question2\n", "import numpy as np\n", "while True:\n", " try:\n", " sum_entry=int(input(\"Name your price: \"))\n", " assert sum_entry>=df.price.min()\n", " break\n", " except ValueError:\n", " print(\"Wrong Entry\")\n", " except AssertionError:\n", " print(\"Your entry should be greater than 4!\")\n", "k1=df.loc[df.loc[:,\"price\"]<=sum_entry]\n", "best1=k1.points/k.price\n", "k1.insert(2,\"Best\",best1,allow_duplicates=False)\n", "best_drink1=k1.loc[k.loc[:,\"Best\"]==np.nanmax(best1)]\n", "print(\"\\nThe best drinks are:\")\n", "best_drink1" ] }, { "cell_type": "code", "execution_count": null, "id": "1c1b3f73", "metadata": {}, "outputs": [], "source": [ "price_points=df.groupby(\"price\").points.max()\n", "price_points.sort_values(ascending=True)\n", "price_points" ] }, { "cell_type": "code", "execution_count": 2, "id": "a75c10cc", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4.0" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.price.min()" ] } ], "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" } }, "nbformat": 4, "nbformat_minor": 5 }
About
No description, website, or topics provided.
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published