Skip to content

Instantly share code, notes, and snippets.

@yogeshchappewar
Created December 27, 2022 05:54
Show Gist options
  • Save yogeshchappewar/2c36284f29e1db6773e53e1c1a9dcf38 to your computer and use it in GitHub Desktop.
Save yogeshchappewar/2c36284f29e1db6773e53e1c1a9dcf38 to your computer and use it in GitHub Desktop.
Basics_stats_Q7_assignment
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:17:57.210940Z",
"end_time": "2022-12-27T05:17:58.089775Z"
},
"trusted": true
},
"cell_type": "code",
"source": "import pandas as pd",
"execution_count": 1,
"outputs": []
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:18:33.290066Z",
"end_time": "2022-12-27T05:18:33.306623Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df = pd.read_csv('Q7.csv')",
"execution_count": 2,
"outputs": []
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:18:37.332261Z",
"end_time": "2022-12-27T05:18:37.364370Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df",
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 3,
"data": {
"text/plain": " Unnamed: 0 Points Score Weigh\n0 Mazda RX4 3.90 2.620 16.46\n1 Mazda RX4 Wag 3.90 2.875 17.02\n2 Datsun 710 3.85 2.320 18.61\n3 Hornet 4 Drive 3.08 3.215 19.44\n4 Hornet Sportabout 3.15 3.440 17.02\n5 Valiant 2.76 3.460 20.22\n6 Duster 360 3.21 3.570 15.84\n7 Merc 240D 3.69 3.190 20.00\n8 Merc 230 3.92 3.150 22.90\n9 Merc 280 3.92 3.440 18.30\n10 Merc 280C 3.92 3.440 18.90\n11 Merc 450SE 3.07 4.070 17.40\n12 Merc 450SL 3.07 3.730 17.60\n13 Merc 450SLC 3.07 3.780 18.00\n14 Cadillac Fleetwood 2.93 5.250 17.98\n15 Lincoln Continental 3.00 5.424 17.82\n16 Chrysler Imperial 3.23 5.345 17.42\n17 Fiat 128 4.08 2.200 19.47\n18 Honda Civic 4.93 1.615 18.52\n19 Toyota Corolla 4.22 1.835 19.90\n20 Toyota Corona 3.70 2.465 20.01\n21 Dodge Challenger 2.76 3.520 16.87\n22 AMC Javelin 3.15 3.435 17.30\n23 Camaro Z28 3.73 3.840 15.41\n24 Pontiac Firebird 3.08 3.845 17.05\n25 Fiat X1-9 4.08 1.935 18.90\n26 Porsche 914-2 4.43 2.140 16.70\n27 Lotus Europa 3.77 1.513 16.90\n28 Ford Pantera L 4.22 3.170 14.50\n29 Ferrari Dino 3.62 2.770 15.50\n30 Maserati Bora 3.54 3.570 14.60\n31 Volvo 142E 4.11 2.780 18.60",
"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>Unnamed: 0</th>\n <th>Points</th>\n <th>Score</th>\n <th>Weigh</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>Mazda RX4</td>\n <td>3.90</td>\n <td>2.620</td>\n <td>16.46</td>\n </tr>\n <tr>\n <th>1</th>\n <td>Mazda RX4 Wag</td>\n <td>3.90</td>\n <td>2.875</td>\n <td>17.02</td>\n </tr>\n <tr>\n <th>2</th>\n <td>Datsun 710</td>\n <td>3.85</td>\n <td>2.320</td>\n <td>18.61</td>\n </tr>\n <tr>\n <th>3</th>\n <td>Hornet 4 Drive</td>\n <td>3.08</td>\n <td>3.215</td>\n <td>19.44</td>\n </tr>\n <tr>\n <th>4</th>\n <td>Hornet Sportabout</td>\n <td>3.15</td>\n <td>3.440</td>\n <td>17.02</td>\n </tr>\n <tr>\n <th>5</th>\n <td>Valiant</td>\n <td>2.76</td>\n <td>3.460</td>\n <td>20.22</td>\n </tr>\n <tr>\n <th>6</th>\n <td>Duster 360</td>\n <td>3.21</td>\n <td>3.570</td>\n <td>15.84</td>\n </tr>\n <tr>\n <th>7</th>\n <td>Merc 240D</td>\n <td>3.69</td>\n <td>3.190</td>\n <td>20.00</td>\n </tr>\n <tr>\n <th>8</th>\n <td>Merc 230</td>\n <td>3.92</td>\n <td>3.150</td>\n <td>22.90</td>\n </tr>\n <tr>\n <th>9</th>\n <td>Merc 280</td>\n <td>3.92</td>\n <td>3.440</td>\n <td>18.30</td>\n </tr>\n <tr>\n <th>10</th>\n <td>Merc 280C</td>\n <td>3.92</td>\n <td>3.440</td>\n <td>18.90</td>\n </tr>\n <tr>\n <th>11</th>\n <td>Merc 450SE</td>\n <td>3.07</td>\n <td>4.070</td>\n <td>17.40</td>\n </tr>\n <tr>\n <th>12</th>\n <td>Merc 450SL</td>\n <td>3.07</td>\n <td>3.730</td>\n <td>17.60</td>\n </tr>\n <tr>\n <th>13</th>\n <td>Merc 450SLC</td>\n <td>3.07</td>\n <td>3.780</td>\n <td>18.00</td>\n </tr>\n <tr>\n <th>14</th>\n <td>Cadillac Fleetwood</td>\n <td>2.93</td>\n <td>5.250</td>\n <td>17.98</td>\n </tr>\n <tr>\n <th>15</th>\n <td>Lincoln Continental</td>\n <td>3.00</td>\n <td>5.424</td>\n <td>17.82</td>\n </tr>\n <tr>\n <th>16</th>\n <td>Chrysler Imperial</td>\n <td>3.23</td>\n <td>5.345</td>\n <td>17.42</td>\n </tr>\n <tr>\n <th>17</th>\n <td>Fiat 128</td>\n <td>4.08</td>\n <td>2.200</td>\n <td>19.47</td>\n </tr>\n <tr>\n <th>18</th>\n <td>Honda Civic</td>\n <td>4.93</td>\n <td>1.615</td>\n <td>18.52</td>\n </tr>\n <tr>\n <th>19</th>\n <td>Toyota Corolla</td>\n <td>4.22</td>\n <td>1.835</td>\n <td>19.90</td>\n </tr>\n <tr>\n <th>20</th>\n <td>Toyota Corona</td>\n <td>3.70</td>\n <td>2.465</td>\n <td>20.01</td>\n </tr>\n <tr>\n <th>21</th>\n <td>Dodge Challenger</td>\n <td>2.76</td>\n <td>3.520</td>\n <td>16.87</td>\n </tr>\n <tr>\n <th>22</th>\n <td>AMC Javelin</td>\n <td>3.15</td>\n <td>3.435</td>\n <td>17.30</td>\n </tr>\n <tr>\n <th>23</th>\n <td>Camaro Z28</td>\n <td>3.73</td>\n <td>3.840</td>\n <td>15.41</td>\n </tr>\n <tr>\n <th>24</th>\n <td>Pontiac Firebird</td>\n <td>3.08</td>\n <td>3.845</td>\n <td>17.05</td>\n </tr>\n <tr>\n <th>25</th>\n <td>Fiat X1-9</td>\n <td>4.08</td>\n <td>1.935</td>\n <td>18.90</td>\n </tr>\n <tr>\n <th>26</th>\n <td>Porsche 914-2</td>\n <td>4.43</td>\n <td>2.140</td>\n <td>16.70</td>\n </tr>\n <tr>\n <th>27</th>\n <td>Lotus Europa</td>\n <td>3.77</td>\n <td>1.513</td>\n <td>16.90</td>\n </tr>\n <tr>\n <th>28</th>\n <td>Ford Pantera L</td>\n <td>4.22</td>\n <td>3.170</td>\n <td>14.50</td>\n </tr>\n <tr>\n <th>29</th>\n <td>Ferrari Dino</td>\n <td>3.62</td>\n <td>2.770</td>\n <td>15.50</td>\n </tr>\n <tr>\n <th>30</th>\n <td>Maserati Bora</td>\n <td>3.54</td>\n <td>3.570</td>\n <td>14.60</td>\n </tr>\n <tr>\n <th>31</th>\n <td>Volvo 142E</td>\n <td>4.11</td>\n <td>2.780</td>\n <td>18.60</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:22:22.345571Z",
"end_time": "2022-12-27T05:22:22.370422Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.mean()",
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"text": "C:\\Users\\yogesh\\AppData\\Local\\Temp\\ipykernel_12352\\3698961737.py:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.\n df.mean()\n",
"name": "stderr"
},
{
"output_type": "execute_result",
"execution_count": 7,
"data": {
"text/plain": "Points 3.596563\nScore 3.217250\nWeigh 17.848750\ndtype: float64"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:23:33.235263Z",
"end_time": "2022-12-27T05:23:33.251725Z"
},
"trusted": true
},
"cell_type": "code",
"source": "import warnings\nwarnings.filterwarnings('ignore')",
"execution_count": 8,
"outputs": []
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:23:46.647846Z",
"end_time": "2022-12-27T05:23:46.659045Z"
},
"trusted": true
},
"cell_type": "code",
"source": "# average of whole dataset\ndf.mean()",
"execution_count": 9,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 9,
"data": {
"text/plain": "Points 3.596563\nScore 3.217250\nWeigh 17.848750\ndtype: float64"
},
"metadata": {}
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "# points"
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:27:25.783780Z",
"end_time": "2022-12-27T05:27:25.797982Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.mean()",
"execution_count": 14,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 14,
"data": {
"text/plain": "3.5965625000000006"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:27:52.921678Z",
"end_time": "2022-12-27T05:27:52.937871Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.median()",
"execution_count": 15,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 15,
"data": {
"text/plain": "3.6950000000000003"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:28:16.983690Z",
"end_time": "2022-12-27T05:28:17.007599Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.mode()",
"execution_count": 16,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 16,
"data": {
"text/plain": "0 3.07\n1 3.92\nName: Points, dtype: float64"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:28:37.558621Z",
"end_time": "2022-12-27T05:28:37.579511Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.std()",
"execution_count": 17,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 17,
"data": {
"text/plain": "0.5346787360709716"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:28:48.123370Z",
"end_time": "2022-12-27T05:28:48.133023Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.var()",
"execution_count": 18,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 18,
"data": {
"text/plain": "0.28588135080645166"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:30:54.058379Z",
"end_time": "2022-12-27T05:30:54.081961Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.min()",
"execution_count": 20,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 20,
"data": {
"text/plain": "2.76"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:31:15.867779Z",
"end_time": "2022-12-27T05:31:15.883782Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.max()",
"execution_count": 21,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 21,
"data": {
"text/plain": "4.93"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:33:07.544796Z",
"end_time": "2022-12-27T05:33:07.557790Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Points.min()-df.Points.max()",
"execution_count": 25,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 25,
"data": {
"text/plain": "-2.17"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:34:29.850754Z",
"end_time": "2022-12-27T05:34:29.857721Z"
},
"trusted": true
},
"cell_type": "code",
"source": "print(\"Range of points:\",df.Points.min()-df.Points.max())",
"execution_count": 26,
"outputs": [
{
"output_type": "stream",
"text": "Range of points: -2.17\n",
"name": "stdout"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "# score"
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:39:46.308912Z",
"end_time": "2022-12-27T05:39:46.332164Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.mean()",
"execution_count": 28,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 28,
"data": {
"text/plain": "3.2172499999999995"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:40:18.776178Z",
"end_time": "2022-12-27T05:40:18.792690Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.median()",
"execution_count": 29,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 29,
"data": {
"text/plain": "3.325"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:41:01.822522Z",
"end_time": "2022-12-27T05:41:01.838932Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.mode()",
"execution_count": 30,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 30,
"data": {
"text/plain": "0 3.44\nName: Score, dtype: float64"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:41:29.419114Z",
"end_time": "2022-12-27T05:41:29.435293Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.std()",
"execution_count": 31,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 31,
"data": {
"text/plain": "0.9784574429896967"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:41:37.176410Z",
"end_time": "2022-12-27T05:41:37.196047Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.var()",
"execution_count": 32,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 32,
"data": {
"text/plain": "0.9573789677419356"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:41:51.685795Z",
"end_time": "2022-12-27T05:41:51.701891Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.min()",
"execution_count": 33,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 33,
"data": {
"text/plain": "1.513"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:41:59.108368Z",
"end_time": "2022-12-27T05:41:59.132521Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.max()",
"execution_count": 34,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 34,
"data": {
"text/plain": "5.424"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:42:26.569107Z",
"end_time": "2022-12-27T05:42:26.584044Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Score.min()-df.Score.max()",
"execution_count": 35,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 35,
"data": {
"text/plain": "-3.9110000000000005"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:43:15.623124Z",
"end_time": "2022-12-27T05:43:15.639150Z"
},
"trusted": true
},
"cell_type": "code",
"source": "print(\"range of score:\",df.Score.min()-df.Score.max())",
"execution_count": 36,
"outputs": [
{
"output_type": "stream",
"text": "range of score: -3.9110000000000005\n",
"name": "stdout"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "# Weigh"
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:44:38.598933Z",
"end_time": "2022-12-27T05:44:38.620167Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.mean()",
"execution_count": 38,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 38,
"data": {
"text/plain": "17.848750000000003"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:45:48.357243Z",
"end_time": "2022-12-27T05:45:48.367776Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.median()",
"execution_count": 39,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 39,
"data": {
"text/plain": "17.71"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:46:18.915708Z",
"end_time": "2022-12-27T05:46:18.939909Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.mode()",
"execution_count": 40,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 40,
"data": {
"text/plain": "0 17.02\n1 18.90\nName: Weigh, dtype: float64"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:46:46.043966Z",
"end_time": "2022-12-27T05:46:46.068278Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.std()",
"execution_count": 41,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 41,
"data": {
"text/plain": "1.7869432360968431"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:46:52.829110Z",
"end_time": "2022-12-27T05:46:52.845419Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.var()",
"execution_count": 42,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 42,
"data": {
"text/plain": "3.193166129032258"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:47:00.382595Z",
"end_time": "2022-12-27T05:47:00.399018Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.max()",
"execution_count": 43,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 43,
"data": {
"text/plain": "22.9"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:47:12.329897Z",
"end_time": "2022-12-27T05:47:12.343624Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.min()",
"execution_count": 44,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 44,
"data": {
"text/plain": "14.5"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:48:06.961434Z",
"end_time": "2022-12-27T05:48:06.975271Z"
},
"trusted": true
},
"cell_type": "code",
"source": "df.Weigh.max()-df.Weigh.min()",
"execution_count": 45,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 45,
"data": {
"text/plain": "8.399999999999999"
},
"metadata": {}
}
]
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2022-12-27T05:49:02.048617Z",
"end_time": "2022-12-27T05:49:02.065149Z"
},
"trusted": true
},
"cell_type": "code",
"source": "print(\"range of weigh:\",df.Weigh.max()-df.Weigh.min())",
"execution_count": 46,
"outputs": [
{
"output_type": "stream",
"text": "range of weigh: 8.399999999999999\n",
"name": "stdout"
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3 (ipykernel)",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.9.13",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Basics_stats_Q7_assignment",
"public": true
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment