diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 406e6ba..14cd9e0 100755 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -18,11 +18,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "# import libraries here" + "# import libraries\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "import seaborn as sns" ] }, { @@ -37,11 +40,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "temp = pd.read_csv('Temp_States.csv')" ] }, { @@ -53,11 +56,100 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# your code here" + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
CityStateTemperature
0NYCNew York19.444444
1AlbanyNew York9.444444
2BuffaloNew York3.333333
3HartfordConnecticut17.222222
4BridgeportConnecticut14.444444
5TretonNew Jersey22.222222
6NewarkNew Jersey20.000000
\n", + "
" + ], + "text/plain": [ + " City State Temperature\n", + "0 NYC New York 19.444444\n", + "1 Albany New York 9.444444\n", + "2 Buffalo New York 3.333333\n", + "3 Hartford Connecticut 17.222222\n", + "4 Bridgeport Connecticut 14.444444\n", + "5 Treton New Jersey 22.222222\n", + "6 Newark New Jersey 20.000000" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "temp" ] }, { @@ -69,11 +161,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "City object\n", + "State object\n", + "Temperature float64\n", + "dtype: object" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "temp.dtypes" ] }, { @@ -83,7 +189,7 @@ "outputs": [], "source": [ "\"\"\"\n", - "your comments here\n", + "We have categorical (state and city) and numerical (temperature)\n", "\"\"\"" ] }, @@ -96,11 +202,11 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "ny_temp = temp[temp['State'] == 'New York']" ] }, { @@ -112,11 +218,31 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# your code here" + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\jsctr\\AppData\\Local\\Temp\\ipykernel_13940\\2632361778.py:1: FutureWarning: The default value of numeric_only in DataFrame.mean is deprecated. In a future version, it will default to False. In addition, specifying 'numeric_only=None' is deprecated. Select only valid columns or specify the value of numeric_only to silence this warning.\n", + " ny_temp.mean()\n" + ] + }, + { + "data": { + "text/plain": [ + "Temperature 10.740741\n", + "dtype: float64" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ny_temp.mean()" ] }, { @@ -128,11 +254,75 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# your code here" + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
CityState
0NYCNew York
3HartfordConnecticut
5TretonNew Jersey
6NewarkNew Jersey
\n", + "
" + ], + "text/plain": [ + " City State\n", + "0 NYC New York\n", + "3 Hartford Connecticut\n", + "5 Treton New Jersey\n", + "6 Newark New Jersey" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "above15 = temp.loc[temp['Temperature'] > 15, ['City', 'State']]\n", + "above15" ] }, { @@ -144,11 +334,27 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# your code here" + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0 NYC\n", + "3 Hartford\n", + "5 Treton\n", + "6 Newark\n", + "Name: City, dtype: object" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "above15_city = temp.loc[temp['Temperature'] > 15, 'City']\n", + "above15_city" ] }, { @@ -162,11 +368,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0 NYC\n", + "3 Hartford\n", + "Name: City, dtype: object" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "between15_and_20 = temp.loc[(temp['Temperature'] > 15) & (temp['Temperature'] < 20), 'City']\n", + "between15_and_20" ] }, { @@ -178,11 +398,120 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# your code here" + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Temperature
countmeanstdmin25%50%75%max
State
Connecticut2.015.8333331.96418614.44444415.13888915.83333316.52777817.222222
New Jersey2.021.1111111.57134820.00000020.55555621.11111121.66666722.222222
New York3.010.7407418.1334043.3333336.3888899.44444414.44444419.444444
\n", + "
" + ], + "text/plain": [ + " Temperature \\\n", + " count mean std min 25% 50% \n", + "State \n", + "Connecticut 2.0 15.833333 1.964186 14.444444 15.138889 15.833333 \n", + "New Jersey 2.0 21.111111 1.571348 20.000000 20.555556 21.111111 \n", + "New York 3.0 10.740741 8.133404 3.333333 6.388889 9.444444 \n", + "\n", + " \n", + " 75% max \n", + "State \n", + "Connecticut 16.527778 17.222222 \n", + "New Jersey 21.666667 22.222222 \n", + "New York 14.444444 19.444444 " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "temp.groupby('State').describe()" ] }, { @@ -799,7 +1128,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.10.9" } }, "nbformat": 4,