You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ML-For-Beginners/2-Regression/2-Data/solution/notebook.ipynb

229 lines
114 KiB

4 years ago
{
"metadata": {
"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.3-final"
},
"orig_nbformat": 2,
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"cell_type": "code",
"execution_count": 22,
4 years ago
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" City Name Type Package Variety Sub Variety Grade \\\n",
"70 BALTIMORE NaN 1 1/9 bushel cartons PIE TYPE NaN NaN \n",
"71 BALTIMORE NaN 1 1/9 bushel cartons PIE TYPE NaN NaN \n",
"72 BALTIMORE NaN 1 1/9 bushel cartons PIE TYPE NaN NaN \n",
"73 BALTIMORE NaN 1 1/9 bushel cartons PIE TYPE NaN NaN \n",
"74 BALTIMORE NaN 1 1/9 bushel cartons PIE TYPE NaN NaN \n",
"\n",
" Date Low Price High Price Mostly Low ... Unit of Sale Quality \\\n",
"70 9/24/16 15.0 15.0 15.0 ... NaN NaN \n",
"71 9/24/16 18.0 18.0 18.0 ... NaN NaN \n",
"72 10/1/16 18.0 18.0 18.0 ... NaN NaN \n",
"73 10/1/16 17.0 17.0 17.0 ... NaN NaN \n",
"74 10/8/16 15.0 15.0 15.0 ... NaN NaN \n",
"\n",
" Condition Appearance Storage Crop Repack Trans Mode Unnamed: 24 \\\n",
"70 NaN NaN NaN NaN N NaN NaN \n",
"71 NaN NaN NaN NaN N NaN NaN \n",
"72 NaN NaN NaN NaN N NaN NaN \n",
"73 NaN NaN NaN NaN N NaN NaN \n",
"74 NaN NaN NaN NaN N NaN NaN \n",
"\n",
" Unnamed: 25 \n",
"70 NaN \n",
"71 NaN \n",
"72 NaN \n",
"73 NaN \n",
"74 NaN \n",
"\n",
"[5 rows x 26 columns]"
],
"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>City Name</th>\n <th>Type</th>\n <th>Package</th>\n <th>Variety</th>\n <th>Sub Variety</th>\n <th>Grade</th>\n <th>Date</th>\n <th>Low Price</th>\n <th>High Price</th>\n <th>Mostly Low</th>\n <th>...</th>\n <th>Unit of Sale</th>\n <th>Quality</th>\n <th>Condition</th>\n <th>Appearance</th>\n <th>Storage</th>\n <th>Crop</th>\n <th>Repack</th>\n <th>Trans Mode</th>\n <th>Unnamed: 24</th>\n <th>Unnamed: 25</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>70</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>1 1/9 bushel cartons</td>\n <td>PIE TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>9/24/16</td>\n <td>15.0</td>\n <td>15.0</td>\n <td>15.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>71</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>1 1/9 bushel cartons</td>\n <td>PIE TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>9/24/16</td>\n <td>18.0</td>\n <td>18.0</td>\n <td>18.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>72</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>1 1/9 bushel cartons</td>\n <td>PIE TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>10/1/16</td>\n <td>18.0</td>\n <td>18.0</td>\n <td>18.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>73</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>1 1/9 bushel cartons</td>\n <td>PIE TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>10/1/16</td>\n <td>17.0</td>\n <td>17.0</td>\n <td>17.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>74</th>\n <td>BALTIMORE</td>\n <td>NaN</td>\n <td>1 1/9 bushel cartons</td>\n <td>PIE TYPE</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>10/8/16</td>\n <td>15.0</td>\n <td>15.0</td>\n <td>15.0</td>\n <td>...</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>N</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n </tbody>\n</table>\n<p>5 rows × 26 columns</p>\n</div>"
},
"metadata": {},
"execution_count": 22
4 years ago
}
],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"pumpkins = pd.read_csv('../../data/US-pumpkins.csv')\n",
4 years ago
"\n",
"pumpkins = pumpkins[pumpkins['Package'].str.contains('bushel', case=True, regex=True)]\n",
"\n",
"pumpkins.head()"
]
},
{
"cell_type": "code",
"execution_count": 23,
4 years ago
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"City Name 0\n",
"Type 406\n",
"Package 0\n",
"Variety 0\n",
"Sub Variety 167\n",
"Grade 415\n",
"Date 0\n",
"Low Price 0\n",
"High Price 0\n",
"Mostly Low 24\n",
"Mostly High 24\n",
"Origin 0\n",
"Origin District 396\n",
"Item Size 114\n",
"Color 180\n",
"Environment 415\n",
"Unit of Sale 404\n",
"Quality 415\n",
"Condition 415\n",
"Appearance 415\n",
"Storage 415\n",
"Crop 415\n",
"Repack 0\n",
"Trans Mode 415\n",
"Unnamed: 24 415\n",
"Unnamed: 25 391\n",
"dtype: int64"
]
},
"metadata": {},
"execution_count": 23
4 years ago
}
],
"source": [
"pumpkins.isnull().sum()"
]
},
{
"cell_type": "code",
"execution_count": 24,
4 years ago
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
" Month Package Low Price High Price Price\n70 9 1 1/9 bushel cartons 15.00 15.0 13.636364\n71 9 1 1/9 bushel cartons 18.00 18.0 16.363636\n72 10 1 1/9 bushel cartons 18.00 18.0 16.363636\n73 10 1 1/9 bushel cartons 17.00 17.0 15.454545\n74 10 1 1/9 bushel cartons 15.00 15.0 13.636364\n... ... ... ... ... ...\n1738 9 1/2 bushel cartons 15.00 15.0 30.000000\n1739 9 1/2 bushel cartons 13.75 15.0 28.750000\n1740 9 1/2 bushel cartons 10.75 15.0 25.750000\n1741 9 1/2 bushel cartons 12.00 12.0 24.000000\n1742 9 1/2 bushel cartons 12.00 12.0 24.000000\n\n[415 rows x 5 columns]\n"
]
}
],
"source": [
"\n",
"# A set of new columns for a new dataframe. Filter out nonmatching columns\n",
"new_columns = ['Package', 'Month', 'Low Price', 'High Price', 'Date']\n",
"pumpkins = pumpkins.drop([c for c in pumpkins.columns if c not in new_columns], axis=1)\n",
"\n",
"# Get an average between low and high price for the base pumpkin price\n",
"price = (pumpkins['Low Price'] + pumpkins['High Price']) / 2\n",
"\n",
"# Convert the date to its month only\n",
"month = pd.DatetimeIndex(pumpkins['Date']).month\n",
"\n",
"# Create a new dataframe with this basic data\n",
"new_pumpkins = pd.DataFrame({'Month': month, 'Package': pumpkins['Package'], 'Low Price': pumpkins['Low Price'],'High Price': pumpkins['High Price'], 'Price': price})\n",
"\n",
"# Convert the price if the Package contains fractional bushel values\n",
"new_pumpkins.loc[new_pumpkins['Package'].str.contains('1 1/9'), 'Price'] = price/1.1\n",
"\n",
"new_pumpkins.loc[new_pumpkins['Package'].str.contains('1/2'), 'Price'] = price*2\n",
"\n",
"print(new_pumpkins)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 45,
4 years ago
"metadata": {},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"248.518125pt\" version=\"1.1\" viewBox=\"0 0 378.465625 248.518125\" width=\"378.465625pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <defs>\n <style type=\"text/css\">\n*{stroke-linecap:butt;stroke-linejoin:round;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 248.518125 \nL 378.465625 248.518125 \nL 378.465625 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 36.465625 224.64 \nL 371.265625 224.64 \nL 371.265625 7.2 \nL 36.465625 7.2 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"PathCollection_1\">\n <defs>\n <path d=\"M 0 3 \nC 0.795609 3 1.55874 2.683901 2.12132 2.12132 \nC 2.683901 1.55874 3 0.795609 3 0 \nC 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \nC 1.55874 -2.683901 0.795609 -3 0 -3 \nC -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \nC -2.683901 -1.55874 -3 -0.795609 -3 0 \nC -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \nC -1.55874 2.683901 -0.795609 3 0 3 \nz\n\" id=\"mf024e9613a\" style=\"stroke:#1f77b4;\"/>\n </defs>\n <g clip-path=\"url(#p9b284abf90)\">\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"72.133771\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"92.583736\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"92.583736\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"85.767081\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"72.133771\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"92.583736\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"85.767081\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"90.879572\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"72.133771\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"85.767081\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"90.879572\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"72.133771\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"85.767081\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"90.879572\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"72.133771\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"82.358753\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"85.767081\" xlink:href=\"#mf024e9613a\" y=\"115.92\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"92.583736\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"78.950426\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"92.583736\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"78.950426\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"78.950426\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"78.950426\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=\"fill:#1f77b4;stroke:#1f77b4;\" x=\"239.823479\" xlink:href=\"#mf024e9613a\" y=\"165.338182\"/>\n <use style=
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgA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tZvZ9NH7wOeAA+X9RESkuWq5vHIH8AIw38yOmtmXgC3AcjM7BCyPHmNms8zsqWjRmcA/mNkrwE+AJ9396WbshIiIJDurWgd3X5fw1Gdi+g4Aq6L7bwKfSlWdiIikpr+MFREJnIJeRCRwCnoRkcAp6EVEAqegFxEJnIJeRCRwCnoRkcAp6EVEAqegFxEJnIJeRCRwCnoRkcAp6EVEAqegFxEJnIJeRCRwCnoRkcAp6EVEAlf1i0fMbDtwAzDo7ldGbTOAvwXmAoeBf+vuv4pZdiXwIJADvunuWyas8jLL73+OQ4MfjD3u6Wpn98ZlAPTu72frroMMnBhmVkcbm1bMZ83C7rrWF+fwltXj1t1/YrjhfVg6bwaP3XpNTX0X37ebY7/+aOzxzOlns/fO5bF9K41NKObe/uS4tsNbVqde9pN3P817vxkZaz//nByv3rNy7HGluVWtpkrPN7Jsd0dbTXP8rt4+duw9wog7OTPWLZ7NvWsWxPYtd9ntT+Iljw14awLGeTKdCa+HcubulTuYXQu8D3y7JOj/G3Dc3beY2e3ABe7+52XL5YCfUfyqwaPAi8A6d//HakXl83kvFAo170RSKPd0tXPbdT3csbOP4ZO/fbG2Tcuxee2CxBdCLSFfuq7SdadVS9iXh/youLCvNDahTO64ABlVLUgqLXv+ObnTQr60/dV7VtK7vz9xbn3tb1+uWFOl7VZS67JJc/yu3j6+s+ftcf3XL5l
4 years ago
},
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"\n",
"price = new_pumpkins.Price\n",
"month = new_pumpkins.Month\n",
"plt.scatter(price, month)\n",
"plt.show()\n"
4 years ago
]
},
{
"cell_type": "code",
"execution_count": 48,
4 years ago
"metadata": {},
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"Text(0, 0.5, 'Pumpkin Price')"
]
},
"metadata": {},
"execution_count": 48
4 years ago
},
{
"output_type": "display_data",
"data": {
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"268.931746pt\" version=\"1.1\" viewBox=\"0 0 382.603125 268.931746\" width=\"382.603125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <defs>\n <style type=\"text/css\">\n*{stroke-linecap:butt;stroke-linejoin:round;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 268.931746 \nL 382.603125 268.931746 \nL 382.603125 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 40.603125 228.328621 \nL 375.403125 228.328621 \nL 375.403125 10.888621 \nL 40.603125 10.888621 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"patch_3\">\n <path clip-path=\"url(#pd7233fdb66)\" d=\"M 57.343125 228.328621 \nL 90.823125 228.328621 \nL 90.823125 50.952705 \nL 57.343125 50.952705 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_4\">\n <path clip-path=\"url(#pd7233fdb66)\" d=\"M 124.303125 228.328621 \nL 157.783125 228.328621 \nL 157.783125 21.242907 \nL 124.303125 21.242907 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_5\">\n <path clip-path=\"url(#pd7233fdb66)\" d=\"M 191.263125 228.328621 \nL 224.743125 228.328621 \nL 224.743125 22.59012 \nL 191.263125 22.59012 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_6\">\n <path clip-path=\"url(#pd7233fdb66)\" d=\"M 258.223125 228.328621 \nL 291.703125 228.328621 \nL 291.703125 46.205934 \nL 258.223125 46.205934 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"patch_7\">\n <path clip-path=\"url(#pd7233fdb66)\" d=\"M 325.183125 228.328621 \nL 358.663125 228.328621 \nL 358.663125 115.547833 \nL 325.183125 115.547833 \nz\n\" style=\"fill:#1f77b4;\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <defs>\n <path d=\"M 0 0 \nL 0 3.5 \n\" id=\"mbb69e6040a\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"74.083125\" xlink:href=\"#mbb69e6040a\" y=\"228.328621\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 8 -->\n <defs>\n <path d=\"M 31.78125 34.625 \nQ 24.75 34.625 20.71875 30.859375 \nQ 16.703125 27.09375 16.703125 20.515625 \nQ 16.703125 13.921875 20.71875 10.15625 \nQ 24.75 6.390625 31.78125 6.390625 \nQ 38.8125 6.390625 42.859375 10.171875 \nQ 46.921875 13.96875 46.921875 20.515625 \nQ 46.921875 27.09375 42.890625 30.859375 \nQ 38.875 34.625 31.78125 34.625 \nz\nM 21.921875 38.8125 \nQ 15.578125 40.375 12.03125 44.71875 \nQ 8.5 49.078125 8.5 55.328125 \nQ 8.5 64.0625 14.71875 69.140625 \nQ 20.953125 74.21875 31.78125 74.21875 \nQ 42.671875 74.21875 48.875 69.140625 \nQ 55.078125 64.0625 55.078125 55.328125 \nQ 55.078125 49.078125 51.53125 44.71875 \nQ 48 40.375 41.703125 38.8125 \nQ 48.828125 37.15625 52.796875 32.3125 \nQ 56.78125 27.484375 56.78125 20.515625 \nQ 56.78125 9.90625 50.3125 4.234375 \nQ 43.84375 -1.421875 31.78125 -1.421875 \nQ 19.734375 -1.421875 13.25 4.234375 \nQ 6.78125 9.90625 6.78125 20.515625 \nQ 6.78125 27.484375 10.78125 32.3125 \nQ 14.796875 37.15625 21.921875 38.8125 \nz\nM 18.3125 54.390625 \nQ 18.3125 48.734375 21.84375 45.5625 \nQ 25.390625 42.390625 31.78125 42.390625 \nQ 38.140625 42.390625 41.71875 45.5625 \nQ 45.3125 48.734375 45.3125 54.390625 \nQ 45.3125 60.0625 41.71875 63.234375 \nQ 38.140625 66.40625 31.78125 66.40625 \nQ 25.390625 66.40625 21.84375 63.234375 \nQ 18.3125 60.0625 18.3125 54.390625 \nz\n\" id=\"DejaVuSans-56\"/>\n </defs>\n <g transform=\"translate(76.8425 241.691121)rotate(-90)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-56\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_2\">\n <g id=\"line2d_2\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"141.043125\" xlink:hr
4 years ago
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAENCAYAAAAIbA6TAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAR7ElEQVR4nO3dfbAddX3H8fdHoEV5ENALjUqIUkZEi8FG6hTHokiL4AM+tBU7mlY70bE+UB1rlLZi+0+sqNOxahsLGh3QYn2Agk8IKvUJDBohNjgogxaJEBQEa0sNfPvH2ZhLcu/l5DZ79ia/92vmzNn97Z7db1b8nL2/89vdVBWSpHbcb+gCJEmTZfBLUmMMfklqjMEvSY0x+CWpMQa/JDWmt+BPsneSK5N8K8m3k7y5az8oySVJruveD+yrBknS9tLXOP4kAfapqp8l2Qv4EvBq4DnAT6pqVZKVwIFV9fpeipAkbae3M/4a+Vk3u1f3KuBZwJqufQ1wal81SJK212sff5I9kqwDbgEuqaorgEOqaiNA935wnzVIku5tzz43XlV3A0uTHAB8PMljxv1skhXACoB99tnnN4888sieqpSk3dNVV111a1VNbdvea/BvUVW3J/kCcBJwc5JFVbUxySJGfw3M9JnVwGqAZcuW1dq1aydRqiTtNpJ8f6b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kOOLGblyRN0Di3bJiXqjptlkUn9LVPSdJ9W7A/7kqS+mHwS1JjDH5JaozBL0mNMfglqTEGvyQ1xuCXpMYY/JLUGINfkhpj8EtSYwx+SWqMwS9JjTH4JakxBr8kNcbgl6TGGPyS1BiDX5IaY/BLUmMMfklqjME
},
"metadata": {
"needs_background": "light"
}
}
],
"source": [
"\n",
"new_pumpkins.groupby(['Month'])['Price'].mean().plot(kind='bar')\n",
"plt.ylabel(\"Pumpkin Price\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
]
}