diff --git a/your-code/main.ipynb b/your-code/main.ipynb
index 68b3762..00e6cd4 100644
--- a/your-code/main.ipynb
+++ b/your-code/main.ipynb
@@ -12,11 +12,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
- "#Import your libraries\n"
+ "from sklearn.datasets import load_iris\n",
+ "import numpy as np\n",
+ "import pandas as pd\n",
+ "import seaborn as sns\n"
]
},
{
@@ -38,11 +41,168 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Date | \n",
+ " TempHighF | \n",
+ " TempAvgF | \n",
+ " TempLowF | \n",
+ " DewPointHighF | \n",
+ " DewPointAvgF | \n",
+ " DewPointLowF | \n",
+ " HumidityHighPercent | \n",
+ " HumidityAvgPercent | \n",
+ " HumidityLowPercent | \n",
+ " ... | \n",
+ " SeaLevelPressureAvgInches | \n",
+ " SeaLevelPressureLowInches | \n",
+ " VisibilityHighMiles | \n",
+ " VisibilityAvgMiles | \n",
+ " VisibilityLowMiles | \n",
+ " WindHighMPH | \n",
+ " WindAvgMPH | \n",
+ " WindGustMPH | \n",
+ " PrecipitationSumInches | \n",
+ " Events | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2013-12-21 | \n",
+ " 74 | \n",
+ " 60 | \n",
+ " 45 | \n",
+ " 67 | \n",
+ " 49 | \n",
+ " 43 | \n",
+ " 93 | \n",
+ " 75 | \n",
+ " 57 | \n",
+ " ... | \n",
+ " 29.68 | \n",
+ " 29.59 | \n",
+ " 10 | \n",
+ " 7 | \n",
+ " 2 | \n",
+ " 20 | \n",
+ " 4 | \n",
+ " 31 | \n",
+ " 0.46 | \n",
+ " Rain , Thunderstorm | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2013-12-22 | \n",
+ " 56 | \n",
+ " 48 | \n",
+ " 39 | \n",
+ " 43 | \n",
+ " 36 | \n",
+ " 28 | \n",
+ " 93 | \n",
+ " 68 | \n",
+ " 43 | \n",
+ " ... | \n",
+ " 30.13 | \n",
+ " 29.87 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 5 | \n",
+ " 16 | \n",
+ " 6 | \n",
+ " 25 | \n",
+ " 0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2013-12-23 | \n",
+ " 58 | \n",
+ " 45 | \n",
+ " 32 | \n",
+ " 31 | \n",
+ " 27 | \n",
+ " 23 | \n",
+ " 76 | \n",
+ " 52 | \n",
+ " 27 | \n",
+ " ... | \n",
+ " 30.49 | \n",
+ " 30.41 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 8 | \n",
+ " 3 | \n",
+ " 12 | \n",
+ " 0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
3 rows × 21 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Date TempHighF TempAvgF TempLowF DewPointHighF DewPointAvgF \\\n",
+ "0 2013-12-21 74 60 45 67 49 \n",
+ "1 2013-12-22 56 48 39 43 36 \n",
+ "2 2013-12-23 58 45 32 31 27 \n",
+ "\n",
+ " DewPointLowF HumidityHighPercent HumidityAvgPercent HumidityLowPercent ... \\\n",
+ "0 43 93 75 57 ... \n",
+ "1 28 93 68 43 ... \n",
+ "2 23 76 52 27 ... \n",
+ "\n",
+ " SeaLevelPressureAvgInches SeaLevelPressureLowInches VisibilityHighMiles \\\n",
+ "0 29.68 29.59 10 \n",
+ "1 30.13 29.87 10 \n",
+ "2 30.49 30.41 10 \n",
+ "\n",
+ " VisibilityAvgMiles VisibilityLowMiles WindHighMPH WindAvgMPH WindGustMPH \\\n",
+ "0 7 2 20 4 31 \n",
+ "1 10 5 16 6 25 \n",
+ "2 10 10 8 3 12 \n",
+ "\n",
+ " PrecipitationSumInches Events \n",
+ "0 0.46 Rain , Thunderstorm \n",
+ "1 0 \n",
+ "2 0 \n",
+ "\n",
+ "[3 rows x 21 columns]"
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin=pd.read_csv(\"austin_weather.csv\")\n",
+ "austin.head(3)"
]
},
{
@@ -57,29 +217,396 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Date | \n",
+ " TempHighF | \n",
+ " TempAvgF | \n",
+ " TempLowF | \n",
+ " DewPointHighF | \n",
+ " DewPointAvgF | \n",
+ " DewPointLowF | \n",
+ " HumidityHighPercent | \n",
+ " HumidityAvgPercent | \n",
+ " HumidityLowPercent | \n",
+ " ... | \n",
+ " SeaLevelPressureAvgInches | \n",
+ " SeaLevelPressureLowInches | \n",
+ " VisibilityHighMiles | \n",
+ " VisibilityAvgMiles | \n",
+ " VisibilityLowMiles | \n",
+ " WindHighMPH | \n",
+ " WindAvgMPH | \n",
+ " WindGustMPH | \n",
+ " PrecipitationSumInches | \n",
+ " Events | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2013-12-21 | \n",
+ " 74 | \n",
+ " 60 | \n",
+ " 45 | \n",
+ " 67 | \n",
+ " 49 | \n",
+ " 43 | \n",
+ " 93 | \n",
+ " 75 | \n",
+ " 57 | \n",
+ " ... | \n",
+ " 29.68 | \n",
+ " 29.59 | \n",
+ " 10 | \n",
+ " 7 | \n",
+ " 2 | \n",
+ " 20 | \n",
+ " 4 | \n",
+ " 31 | \n",
+ " 0.46 | \n",
+ " Rain , Thunderstorm | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2013-12-22 | \n",
+ " 56 | \n",
+ " 48 | \n",
+ " 39 | \n",
+ " 43 | \n",
+ " 36 | \n",
+ " 28 | \n",
+ " 93 | \n",
+ " 68 | \n",
+ " 43 | \n",
+ " ... | \n",
+ " 30.13 | \n",
+ " 29.87 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 5 | \n",
+ " 16 | \n",
+ " 6 | \n",
+ " 25 | \n",
+ " 0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2013-12-23 | \n",
+ " 58 | \n",
+ " 45 | \n",
+ " 32 | \n",
+ " 31 | \n",
+ " 27 | \n",
+ " 23 | \n",
+ " 76 | \n",
+ " 52 | \n",
+ " 27 | \n",
+ " ... | \n",
+ " 30.49 | \n",
+ " 30.41 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 8 | \n",
+ " 3 | \n",
+ " 12 | \n",
+ " 0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 2013-12-24 | \n",
+ " 61 | \n",
+ " 46 | \n",
+ " 31 | \n",
+ " 36 | \n",
+ " 28 | \n",
+ " 21 | \n",
+ " 89 | \n",
+ " 56 | \n",
+ " 22 | \n",
+ " ... | \n",
+ " 30.45 | \n",
+ " 30.3 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 7 | \n",
+ " 12 | \n",
+ " 4 | \n",
+ " 20 | \n",
+ " 0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 2013-12-25 | \n",
+ " 58 | \n",
+ " 50 | \n",
+ " 41 | \n",
+ " 44 | \n",
+ " 40 | \n",
+ " 36 | \n",
+ " 86 | \n",
+ " 71 | \n",
+ " 56 | \n",
+ " ... | \n",
+ " 30.33 | \n",
+ " 30.27 | \n",
+ " 10 | \n",
+ " 10 | \n",
+ " 7 | \n",
+ " 10 | \n",
+ " 2 | \n",
+ " 16 | \n",
+ " T | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5 rows × 21 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Date TempHighF TempAvgF TempLowF DewPointHighF DewPointAvgF \\\n",
+ "0 2013-12-21 74 60 45 67 49 \n",
+ "1 2013-12-22 56 48 39 43 36 \n",
+ "2 2013-12-23 58 45 32 31 27 \n",
+ "3 2013-12-24 61 46 31 36 28 \n",
+ "4 2013-12-25 58 50 41 44 40 \n",
+ "\n",
+ " DewPointLowF HumidityHighPercent HumidityAvgPercent HumidityLowPercent ... \\\n",
+ "0 43 93 75 57 ... \n",
+ "1 28 93 68 43 ... \n",
+ "2 23 76 52 27 ... \n",
+ "3 21 89 56 22 ... \n",
+ "4 36 86 71 56 ... \n",
+ "\n",
+ " SeaLevelPressureAvgInches SeaLevelPressureLowInches VisibilityHighMiles \\\n",
+ "0 29.68 29.59 10 \n",
+ "1 30.13 29.87 10 \n",
+ "2 30.49 30.41 10 \n",
+ "3 30.45 30.3 10 \n",
+ "4 30.33 30.27 10 \n",
+ "\n",
+ " VisibilityAvgMiles VisibilityLowMiles WindHighMPH WindAvgMPH WindGustMPH \\\n",
+ "0 7 2 20 4 31 \n",
+ "1 10 5 16 6 25 \n",
+ "2 10 10 8 3 12 \n",
+ "3 10 7 12 4 20 \n",
+ "4 10 7 10 2 16 \n",
+ "\n",
+ " PrecipitationSumInches Events \n",
+ "0 0.46 Rain , Thunderstorm \n",
+ "1 0 \n",
+ "2 0 \n",
+ "3 0 \n",
+ "4 T \n",
+ "\n",
+ "[5 rows x 21 columns]"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin.head(5)"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array(['Rain , Thunderstorm', ' ', 'Rain', 'Fog', 'Rain , Snow',\n",
+ " 'Fog , Rain', 'Thunderstorm', 'Fog , Rain , Thunderstorm',\n",
+ " 'Fog , Thunderstorm'], dtype=object)"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Your code here\n"
+ "austin[\"Events\"].unique()"
]
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "RangeIndex: 1319 entries, 0 to 1318\n",
+ "Data columns (total 21 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 Date 1319 non-null object\n",
+ " 1 TempHighF 1319 non-null int64 \n",
+ " 2 TempAvgF 1319 non-null int64 \n",
+ " 3 TempLowF 1319 non-null int64 \n",
+ " 4 DewPointHighF 1319 non-null object\n",
+ " 5 DewPointAvgF 1319 non-null object\n",
+ " 6 DewPointLowF 1319 non-null object\n",
+ " 7 HumidityHighPercent 1319 non-null object\n",
+ " 8 HumidityAvgPercent 1319 non-null object\n",
+ " 9 HumidityLowPercent 1319 non-null object\n",
+ " 10 SeaLevelPressureHighInches 1319 non-null object\n",
+ " 11 SeaLevelPressureAvgInches 1319 non-null object\n",
+ " 12 SeaLevelPressureLowInches 1319 non-null object\n",
+ " 13 VisibilityHighMiles 1319 non-null object\n",
+ " 14 VisibilityAvgMiles 1319 non-null object\n",
+ " 15 VisibilityLowMiles 1319 non-null object\n",
+ " 16 WindHighMPH 1319 non-null object\n",
+ " 17 WindAvgMPH 1319 non-null object\n",
+ " 18 WindGustMPH 1319 non-null object\n",
+ " 19 PrecipitationSumInches 1319 non-null object\n",
+ " 20 Events 1319 non-null object\n",
+ "dtypes: int64(3), object(18)\n",
+ "memory usage: 216.5+ KB\n"
+ ]
+ }
+ ],
+ "source": [
+ "austin.info()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " TempHighF | \n",
+ " TempAvgF | \n",
+ " TempLowF | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | count | \n",
+ " 1319.000000 | \n",
+ " 1319.000000 | \n",
+ " 1319.000000 | \n",
+ "
\n",
+ " \n",
+ " | mean | \n",
+ " 80.862775 | \n",
+ " 70.642911 | \n",
+ " 59.902957 | \n",
+ "
\n",
+ " \n",
+ " | std | \n",
+ " 14.766523 | \n",
+ " 14.045904 | \n",
+ " 14.190648 | \n",
+ "
\n",
+ " \n",
+ " | min | \n",
+ " 32.000000 | \n",
+ " 29.000000 | \n",
+ " 19.000000 | \n",
+ "
\n",
+ " \n",
+ " | 25% | \n",
+ " 72.000000 | \n",
+ " 62.000000 | \n",
+ " 49.000000 | \n",
+ "
\n",
+ " \n",
+ " | 50% | \n",
+ " 83.000000 | \n",
+ " 73.000000 | \n",
+ " 63.000000 | \n",
+ "
\n",
+ " \n",
+ " | 75% | \n",
+ " 92.000000 | \n",
+ " 83.000000 | \n",
+ " 73.000000 | \n",
+ "
\n",
+ " \n",
+ " | max | \n",
+ " 107.000000 | \n",
+ " 93.000000 | \n",
+ " 81.000000 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " TempHighF TempAvgF TempLowF\n",
+ "count 1319.000000 1319.000000 1319.000000\n",
+ "mean 80.862775 70.642911 59.902957\n",
+ "std 14.766523 14.045904 14.190648\n",
+ "min 32.000000 29.000000 19.000000\n",
+ "25% 72.000000 62.000000 49.000000\n",
+ "50% 83.000000 73.000000 63.000000\n",
+ "75% 92.000000 83.000000 73.000000\n",
+ "max 107.000000 93.000000 81.000000"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin.describe()\n"
]
},
{
@@ -113,20 +640,37 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array(['49', '36', '27', '28', '40', '39', '41', '26', '42', '22', '48',\n",
+ " '32', '8', '11', '45', '55', '61', '37', '47', '25', '23', '20',\n",
+ " '33', '30', '29', '17', '14', '13', '54', '59', '15', '24', '34',\n",
+ " '35', '57', '50', '53', '60', '46', '56', '51', '31', '38', '62',\n",
+ " '43', '63', '64', '67', '66', '58', '70', '68', '65', '69', '71',\n",
+ " '72', '-', '73', '74', '21', '44', '52', '12', '75', '76', '18'],\n",
+ " dtype=object)"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin[\"DewPointAvgF\"].unique()\n"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
- "# Your observation here\n"
+ "# it became an object because we have 1 string between a column, \"-\".\n"
]
},
{
@@ -140,7 +684,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -151,14 +695,282 @@
" 'WindGustMPH', 'PrecipitationSumInches']"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "RangeIndex: 1319 entries, 0 to 1318\n",
+ "Data columns (total 16 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 DewPointHighF 1312 non-null float64\n",
+ " 1 DewPointAvgF 1312 non-null float64\n",
+ " 2 DewPointLowF 1312 non-null float64\n",
+ " 3 HumidityHighPercent 1317 non-null float64\n",
+ " 4 HumidityAvgPercent 1317 non-null float64\n",
+ " 5 HumidityLowPercent 1317 non-null float64\n",
+ " 6 SeaLevelPressureHighInches 1316 non-null float64\n",
+ " 7 SeaLevelPressureAvgInches 1316 non-null float64\n",
+ " 8 SeaLevelPressureLowInches 1316 non-null float64\n",
+ " 9 VisibilityHighMiles 1307 non-null float64\n",
+ " 10 VisibilityAvgMiles 1307 non-null float64\n",
+ " 11 VisibilityLowMiles 1307 non-null float64\n",
+ " 12 WindHighMPH 1317 non-null float64\n",
+ " 13 WindAvgMPH 1317 non-null float64\n",
+ " 14 WindGustMPH 1315 non-null float64\n",
+ " 15 PrecipitationSumInches 1195 non-null float64\n",
+ "dtypes: float64(16)\n",
+ "memory usage: 165.0 KB\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Date | \n",
+ " TempHighF | \n",
+ " TempAvgF | \n",
+ " TempLowF | \n",
+ " DewPointHighF | \n",
+ " DewPointAvgF | \n",
+ " DewPointLowF | \n",
+ " HumidityHighPercent | \n",
+ " HumidityAvgPercent | \n",
+ " HumidityLowPercent | \n",
+ " ... | \n",
+ " SeaLevelPressureAvgInches | \n",
+ " SeaLevelPressureLowInches | \n",
+ " VisibilityHighMiles | \n",
+ " VisibilityAvgMiles | \n",
+ " VisibilityLowMiles | \n",
+ " WindHighMPH | \n",
+ " WindAvgMPH | \n",
+ " WindGustMPH | \n",
+ " PrecipitationSumInches | \n",
+ " Events | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2013-12-21 | \n",
+ " 74 | \n",
+ " 60 | \n",
+ " 45 | \n",
+ " 67.0 | \n",
+ " 49.0 | \n",
+ " 43.0 | \n",
+ " 93.0 | \n",
+ " 75.0 | \n",
+ " 57.0 | \n",
+ " ... | \n",
+ " 29.68 | \n",
+ " 29.59 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 2.0 | \n",
+ " 20.0 | \n",
+ " 4.0 | \n",
+ " 31.0 | \n",
+ " 0.46 | \n",
+ " Rain , Thunderstorm | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2013-12-22 | \n",
+ " 56 | \n",
+ " 48 | \n",
+ " 39 | \n",
+ " 43.0 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 93.0 | \n",
+ " 68.0 | \n",
+ " 43.0 | \n",
+ " ... | \n",
+ " 30.13 | \n",
+ " 29.87 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 5.0 | \n",
+ " 16.0 | \n",
+ " 6.0 | \n",
+ " 25.0 | \n",
+ " 0.00 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2013-12-23 | \n",
+ " 58 | \n",
+ " 45 | \n",
+ " 32 | \n",
+ " 31.0 | \n",
+ " 27.0 | \n",
+ " 23.0 | \n",
+ " 76.0 | \n",
+ " 52.0 | \n",
+ " 27.0 | \n",
+ " ... | \n",
+ " 30.49 | \n",
+ " 30.41 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 8.0 | \n",
+ " 3.0 | \n",
+ " 12.0 | \n",
+ " 0.00 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 2013-12-24 | \n",
+ " 61 | \n",
+ " 46 | \n",
+ " 31 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 21.0 | \n",
+ " 89.0 | \n",
+ " 56.0 | \n",
+ " 22.0 | \n",
+ " ... | \n",
+ " 30.45 | \n",
+ " 30.30 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 12.0 | \n",
+ " 4.0 | \n",
+ " 20.0 | \n",
+ " 0.00 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 2013-12-25 | \n",
+ " 58 | \n",
+ " 50 | \n",
+ " 41 | \n",
+ " 44.0 | \n",
+ " 40.0 | \n",
+ " 36.0 | \n",
+ " 86.0 | \n",
+ " 71.0 | \n",
+ " 56.0 | \n",
+ " ... | \n",
+ " 30.33 | \n",
+ " 30.27 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 10.0 | \n",
+ " 2.0 | \n",
+ " 16.0 | \n",
+ " NaN | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5 rows × 21 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Date TempHighF TempAvgF TempLowF DewPointHighF DewPointAvgF \\\n",
+ "0 2013-12-21 74 60 45 67.0 49.0 \n",
+ "1 2013-12-22 56 48 39 43.0 36.0 \n",
+ "2 2013-12-23 58 45 32 31.0 27.0 \n",
+ "3 2013-12-24 61 46 31 36.0 28.0 \n",
+ "4 2013-12-25 58 50 41 44.0 40.0 \n",
+ "\n",
+ " DewPointLowF HumidityHighPercent HumidityAvgPercent HumidityLowPercent \\\n",
+ "0 43.0 93.0 75.0 57.0 \n",
+ "1 28.0 93.0 68.0 43.0 \n",
+ "2 23.0 76.0 52.0 27.0 \n",
+ "3 21.0 89.0 56.0 22.0 \n",
+ "4 36.0 86.0 71.0 56.0 \n",
+ "\n",
+ " ... SeaLevelPressureAvgInches SeaLevelPressureLowInches \\\n",
+ "0 ... 29.68 29.59 \n",
+ "1 ... 30.13 29.87 \n",
+ "2 ... 30.49 30.41 \n",
+ "3 ... 30.45 30.30 \n",
+ "4 ... 30.33 30.27 \n",
+ "\n",
+ " VisibilityHighMiles VisibilityAvgMiles VisibilityLowMiles WindHighMPH \\\n",
+ "0 10.0 7.0 2.0 20.0 \n",
+ "1 10.0 10.0 5.0 16.0 \n",
+ "2 10.0 10.0 10.0 8.0 \n",
+ "3 10.0 10.0 7.0 12.0 \n",
+ "4 10.0 10.0 7.0 10.0 \n",
+ "\n",
+ " WindAvgMPH WindGustMPH PrecipitationSumInches Events \n",
+ "0 4.0 31.0 0.46 Rain , Thunderstorm \n",
+ "1 6.0 25.0 0.00 \n",
+ "2 3.0 12.0 0.00 \n",
+ "3 4.0 20.0 0.00 \n",
+ "4 2.0 16.0 NaN \n",
+ "\n",
+ "[5 rows x 21 columns]"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ "array([49., 36., 27., 28., 40., 39., 41., 26., 42., 22., 48., 32., 8.,\n",
+ " 11., 45., 55., 61., 37., 47., 25., 23., 20., 33., 30., 29., 17.,\n",
+ " 14., 13., 54., 59., 15., 24., 34., 35., 57., 50., 53., 60., 46.,\n",
+ " 56., 51., 31., 38., 62., 43., 63., 64., 67., 66., 58., 70., 68.,\n",
+ " 65., 69., 71., 72., nan, 73., 74., 21., 44., 52., 12., 75., 76.,\n",
+ " 18.])"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin_2 = austin[wrong_type_columns].apply(pd.to_numeric, errors='coerce')\n",
+ "austin_2.info()\n",
+ "austin[wrong_type_columns]=austin_2\n",
+ "display(austin.head(5))\n",
+ "austin[\"DewPointAvgF\"].unique()"
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": [
- "# Your code here\n"
- ]
+ "source": []
},
{
"cell_type": "markdown",
@@ -169,11 +981,63 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "RangeIndex: 1319 entries, 0 to 1318\n",
+ "Data columns (total 21 columns):\n",
+ " # Column Non-Null Count Dtype \n",
+ "--- ------ -------------- ----- \n",
+ " 0 Date 1319 non-null object \n",
+ " 1 TempHighF 1319 non-null int64 \n",
+ " 2 TempAvgF 1319 non-null int64 \n",
+ " 3 TempLowF 1319 non-null int64 \n",
+ " 4 DewPointHighF 1312 non-null float64\n",
+ " 5 DewPointAvgF 1312 non-null float64\n",
+ " 6 DewPointLowF 1312 non-null float64\n",
+ " 7 HumidityHighPercent 1317 non-null float64\n",
+ " 8 HumidityAvgPercent 1317 non-null float64\n",
+ " 9 HumidityLowPercent 1317 non-null float64\n",
+ " 10 SeaLevelPressureHighInches 1316 non-null float64\n",
+ " 11 SeaLevelPressureAvgInches 1316 non-null float64\n",
+ " 12 SeaLevelPressureLowInches 1316 non-null float64\n",
+ " 13 VisibilityHighMiles 1307 non-null float64\n",
+ " 14 VisibilityAvgMiles 1307 non-null float64\n",
+ " 15 VisibilityLowMiles 1307 non-null float64\n",
+ " 16 WindHighMPH 1317 non-null float64\n",
+ " 17 WindAvgMPH 1317 non-null float64\n",
+ " 18 WindGustMPH 1315 non-null float64\n",
+ " 19 PrecipitationSumInches 1195 non-null float64\n",
+ " 20 Events 1319 non-null object \n",
+ "dtypes: float64(16), int64(3), object(2)\n",
+ "memory usage: 216.5+ KB\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "array([49., 36., 27., 28., 40., 39., 41., 26., 42., 22., 48., 32., 8.,\n",
+ " 11., 45., 55., 61., 37., 47., 25., 23., 20., 33., 30., 29., 17.,\n",
+ " 14., 13., 54., 59., 15., 24., 34., 35., 57., 50., 53., 60., 46.,\n",
+ " 56., 51., 31., 38., 62., 43., 63., 64., 67., 66., 58., 70., 68.,\n",
+ " 65., 69., 71., 72., nan, 73., 74., 21., 44., 52., 12., 75., 76.,\n",
+ " 18.])"
+ ]
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin.head(5)\n",
+ "austin.info()\n",
+ "austin[\"DewPointAvgF\"].unique()"
]
},
{
@@ -200,11 +1064,11 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
- "# Your code here\n"
+ "missing_values=austin[austin.isnull().any(axis=1)]"
]
},
{
@@ -233,11 +1097,73 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Date 1319\n",
+ "TempHighF 1319\n",
+ "TempAvgF 1319\n",
+ "TempLowF 1319\n",
+ "DewPointHighF 1312\n",
+ "DewPointAvgF 1312\n",
+ "DewPointLowF 1312\n",
+ "HumidityHighPercent 1317\n",
+ "HumidityAvgPercent 1317\n",
+ "HumidityLowPercent 1317\n",
+ "SeaLevelPressureHighInches 1316\n",
+ "SeaLevelPressureAvgInches 1316\n",
+ "SeaLevelPressureLowInches 1316\n",
+ "VisibilityHighMiles 1307\n",
+ "VisibilityAvgMiles 1307\n",
+ "VisibilityLowMiles 1307\n",
+ "WindHighMPH 1317\n",
+ "WindAvgMPH 1317\n",
+ "WindGustMPH 1315\n",
+ "PrecipitationSumInches 1195\n",
+ "Events 1319\n",
+ "dtype: int64"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": [
+ "Date 136\n",
+ "TempHighF 136\n",
+ "TempAvgF 136\n",
+ "TempLowF 136\n",
+ "DewPointHighF 129\n",
+ "DewPointAvgF 129\n",
+ "DewPointLowF 129\n",
+ "HumidityHighPercent 134\n",
+ "HumidityAvgPercent 134\n",
+ "HumidityLowPercent 134\n",
+ "SeaLevelPressureHighInches 133\n",
+ "SeaLevelPressureAvgInches 133\n",
+ "SeaLevelPressureLowInches 133\n",
+ "VisibilityHighMiles 124\n",
+ "VisibilityAvgMiles 124\n",
+ "VisibilityLowMiles 124\n",
+ "WindHighMPH 134\n",
+ "WindAvgMPH 134\n",
+ "WindGustMPH 132\n",
+ "PrecipitationSumInches 12\n",
+ "Events 136\n",
+ "dtype: int64"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "display(austin.count())\n",
+ "display(missing_values.count())\n"
]
},
{
@@ -249,11 +1175,23 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "0.10310841546626232"
+ ]
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Your code here\n"
+ "\n",
+ "len(missing_values)/len(austin)"
]
},
{
@@ -267,11 +1205,44 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Date 0\n",
+ "TempHighF 0\n",
+ "TempAvgF 0\n",
+ "TempLowF 0\n",
+ "DewPointHighF 7\n",
+ "DewPointAvgF 7\n",
+ "DewPointLowF 7\n",
+ "HumidityHighPercent 2\n",
+ "HumidityAvgPercent 2\n",
+ "HumidityLowPercent 2\n",
+ "SeaLevelPressureHighInches 3\n",
+ "SeaLevelPressureAvgInches 3\n",
+ "SeaLevelPressureLowInches 3\n",
+ "VisibilityHighMiles 12\n",
+ "VisibilityAvgMiles 12\n",
+ "VisibilityLowMiles 12\n",
+ "WindHighMPH 2\n",
+ "WindAvgMPH 2\n",
+ "WindGustMPH 4\n",
+ "PrecipitationSumInches 124\n",
+ "Events 0\n",
+ "dtype: int64"
+ ]
+ },
+ "execution_count": 15,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Your code here\n"
+ "# Your code here\n",
+ "austin.isna().sum()"
]
},
{
@@ -283,11 +1254,22 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "0.10310841546626232"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Your code here\n"
+ "len(missing_values[\"PrecipitationSumInches\"])/len(austin)"
]
},
{
@@ -309,16 +1291,232 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
- "# Your code here \n",
- "\n",
- "\n",
- "# Print `austin` to confirm the column is indeed removed\n",
- "\n",
- "austin"
+ "austin.drop(columns=[\"PrecipitationSumInches\"], inplace=True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Date | \n",
+ " TempHighF | \n",
+ " TempAvgF | \n",
+ " TempLowF | \n",
+ " DewPointHighF | \n",
+ " DewPointAvgF | \n",
+ " DewPointLowF | \n",
+ " HumidityHighPercent | \n",
+ " HumidityAvgPercent | \n",
+ " HumidityLowPercent | \n",
+ " SeaLevelPressureHighInches | \n",
+ " SeaLevelPressureAvgInches | \n",
+ " SeaLevelPressureLowInches | \n",
+ " VisibilityHighMiles | \n",
+ " VisibilityAvgMiles | \n",
+ " VisibilityLowMiles | \n",
+ " WindHighMPH | \n",
+ " WindAvgMPH | \n",
+ " WindGustMPH | \n",
+ " Events | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2013-12-21 | \n",
+ " 74 | \n",
+ " 60 | \n",
+ " 45 | \n",
+ " 67.0 | \n",
+ " 49.0 | \n",
+ " 43.0 | \n",
+ " 93.0 | \n",
+ " 75.0 | \n",
+ " 57.0 | \n",
+ " 29.86 | \n",
+ " 29.68 | \n",
+ " 29.59 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 2.0 | \n",
+ " 20.0 | \n",
+ " 4.0 | \n",
+ " 31.0 | \n",
+ " Rain , Thunderstorm | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2013-12-22 | \n",
+ " 56 | \n",
+ " 48 | \n",
+ " 39 | \n",
+ " 43.0 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 93.0 | \n",
+ " 68.0 | \n",
+ " 43.0 | \n",
+ " 30.41 | \n",
+ " 30.13 | \n",
+ " 29.87 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 5.0 | \n",
+ " 16.0 | \n",
+ " 6.0 | \n",
+ " 25.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2013-12-23 | \n",
+ " 58 | \n",
+ " 45 | \n",
+ " 32 | \n",
+ " 31.0 | \n",
+ " 27.0 | \n",
+ " 23.0 | \n",
+ " 76.0 | \n",
+ " 52.0 | \n",
+ " 27.0 | \n",
+ " 30.56 | \n",
+ " 30.49 | \n",
+ " 30.41 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 8.0 | \n",
+ " 3.0 | \n",
+ " 12.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 2013-12-24 | \n",
+ " 61 | \n",
+ " 46 | \n",
+ " 31 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 21.0 | \n",
+ " 89.0 | \n",
+ " 56.0 | \n",
+ " 22.0 | \n",
+ " 30.56 | \n",
+ " 30.45 | \n",
+ " 30.30 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 12.0 | \n",
+ " 4.0 | \n",
+ " 20.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 2013-12-25 | \n",
+ " 58 | \n",
+ " 50 | \n",
+ " 41 | \n",
+ " 44.0 | \n",
+ " 40.0 | \n",
+ " 36.0 | \n",
+ " 86.0 | \n",
+ " 71.0 | \n",
+ " 56.0 | \n",
+ " 30.41 | \n",
+ " 30.33 | \n",
+ " 30.27 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 10.0 | \n",
+ " 2.0 | \n",
+ " 16.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Date TempHighF TempAvgF TempLowF DewPointHighF DewPointAvgF \\\n",
+ "0 2013-12-21 74 60 45 67.0 49.0 \n",
+ "1 2013-12-22 56 48 39 43.0 36.0 \n",
+ "2 2013-12-23 58 45 32 31.0 27.0 \n",
+ "3 2013-12-24 61 46 31 36.0 28.0 \n",
+ "4 2013-12-25 58 50 41 44.0 40.0 \n",
+ "\n",
+ " DewPointLowF HumidityHighPercent HumidityAvgPercent HumidityLowPercent \\\n",
+ "0 43.0 93.0 75.0 57.0 \n",
+ "1 28.0 93.0 68.0 43.0 \n",
+ "2 23.0 76.0 52.0 27.0 \n",
+ "3 21.0 89.0 56.0 22.0 \n",
+ "4 36.0 86.0 71.0 56.0 \n",
+ "\n",
+ " SeaLevelPressureHighInches SeaLevelPressureAvgInches \\\n",
+ "0 29.86 29.68 \n",
+ "1 30.41 30.13 \n",
+ "2 30.56 30.49 \n",
+ "3 30.56 30.45 \n",
+ "4 30.41 30.33 \n",
+ "\n",
+ " SeaLevelPressureLowInches VisibilityHighMiles VisibilityAvgMiles \\\n",
+ "0 29.59 10.0 7.0 \n",
+ "1 29.87 10.0 10.0 \n",
+ "2 30.41 10.0 10.0 \n",
+ "3 30.30 10.0 10.0 \n",
+ "4 30.27 10.0 10.0 \n",
+ "\n",
+ " VisibilityLowMiles WindHighMPH WindAvgMPH WindGustMPH \\\n",
+ "0 2.0 20.0 4.0 31.0 \n",
+ "1 5.0 16.0 6.0 25.0 \n",
+ "2 10.0 8.0 3.0 12.0 \n",
+ "3 7.0 12.0 4.0 20.0 \n",
+ "4 7.0 10.0 2.0 16.0 \n",
+ "\n",
+ " Events \n",
+ "0 Rain , Thunderstorm \n",
+ "1 \n",
+ "2 \n",
+ "3 \n",
+ "4 "
+ ]
+ },
+ "execution_count": 18,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin.head()"
]
},
{
@@ -336,11 +1534,11 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
- "# Your code here\n"
+ "austin_fixed=austin.interpolate(inplace=False)"
]
},
{
@@ -352,11 +1550,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 35,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Date 0\n",
+ "TempHighF 0\n",
+ "TempAvgF 0\n",
+ "TempLowF 0\n",
+ "DewPointHighF 0\n",
+ "DewPointAvgF 0\n",
+ "DewPointLowF 0\n",
+ "HumidityHighPercent 0\n",
+ "HumidityAvgPercent 0\n",
+ "HumidityLowPercent 0\n",
+ "SeaLevelPressureHighInches 0\n",
+ "SeaLevelPressureAvgInches 0\n",
+ "SeaLevelPressureLowInches 0\n",
+ "VisibilityHighMiles 0\n",
+ "VisibilityAvgMiles 0\n",
+ "VisibilityLowMiles 0\n",
+ "WindHighMPH 0\n",
+ "WindAvgMPH 0\n",
+ "WindGustMPH 0\n",
+ "Events 0\n",
+ "dtype: int64"
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin_fixed.isna().sum()\n",
+ "austin.isna().sum()"
]
},
{
@@ -377,11 +1607,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n"
+ "execution_count": 38,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Events\n",
+ " 903\n",
+ "Rain 192\n",
+ "Rain , Thunderstorm 137\n",
+ "Fog , Rain , Thunderstorm 33\n",
+ "Fog 21\n",
+ "Thunderstorm 17\n",
+ "Fog , Rain 14\n",
+ "Rain , Snow 1\n",
+ "Fog , Thunderstorm 1\n",
+ "Name: count, dtype: int64"
+ ]
+ },
+ "execution_count": 38,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin_fixed[\"Events\"].value_counts()\n"
]
},
{
@@ -395,11 +1646,11 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
- "# Your answer:\n"
+ "# rain\n"
]
},
{
@@ -415,18 +1666,250 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 44,
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "KeyError",
+ "evalue": "\"['event'] not found in axis\"",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[1;32mIn[44], line 9\u001b[0m\n\u001b[0;32m 7\u001b[0m austin_fixed\u001b[38;5;241m.\u001b[39mdrop(columns\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mevent_fog\u001b[39m\u001b[38;5;124m\"\u001b[39m], inplace\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m 8\u001b[0m austin_fixed\u001b[38;5;241m.\u001b[39mdrop(columns\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mevent_thunderstorm\u001b[39m\u001b[38;5;124m\"\u001b[39m] , inplace\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m----> 9\u001b[0m austin_fixed\u001b[38;5;241m.\u001b[39mdrop(columns\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mevent\u001b[39m\u001b[38;5;124m\"\u001b[39m], inplace\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m 13\u001b[0m \u001b[38;5;66;03m# Print your new dataframe to check whether new columns have been created:\u001b[39;00m\n\u001b[0;32m 15\u001b[0m austin_fixed\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\core\\frame.py:5258\u001b[0m, in \u001b[0;36mDataFrame.drop\u001b[1;34m(self, labels, axis, index, columns, level, inplace, errors)\u001b[0m\n\u001b[0;32m 5110\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdrop\u001b[39m(\n\u001b[0;32m 5111\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 5112\u001b[0m labels: IndexLabel \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 5119\u001b[0m errors: IgnoreRaise \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mraise\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 5120\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m DataFrame \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 5121\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 5122\u001b[0m \u001b[38;5;124;03m Drop specified labels from rows or columns.\u001b[39;00m\n\u001b[0;32m 5123\u001b[0m \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 5256\u001b[0m \u001b[38;5;124;03m weight 1.0 0.8\u001b[39;00m\n\u001b[0;32m 5257\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m-> 5258\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39mdrop(\n\u001b[0;32m 5259\u001b[0m labels\u001b[38;5;241m=\u001b[39mlabels,\n\u001b[0;32m 5260\u001b[0m axis\u001b[38;5;241m=\u001b[39maxis,\n\u001b[0;32m 5261\u001b[0m index\u001b[38;5;241m=\u001b[39mindex,\n\u001b[0;32m 5262\u001b[0m columns\u001b[38;5;241m=\u001b[39mcolumns,\n\u001b[0;32m 5263\u001b[0m level\u001b[38;5;241m=\u001b[39mlevel,\n\u001b[0;32m 5264\u001b[0m inplace\u001b[38;5;241m=\u001b[39minplace,\n\u001b[0;32m 5265\u001b[0m errors\u001b[38;5;241m=\u001b[39merrors,\n\u001b[0;32m 5266\u001b[0m )\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\core\\generic.py:4549\u001b[0m, in \u001b[0;36mNDFrame.drop\u001b[1;34m(self, labels, axis, index, columns, level, inplace, errors)\u001b[0m\n\u001b[0;32m 4547\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m axis, labels \u001b[38;5;129;01min\u001b[39;00m axes\u001b[38;5;241m.\u001b[39mitems():\n\u001b[0;32m 4548\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m labels \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m-> 4549\u001b[0m obj \u001b[38;5;241m=\u001b[39m obj\u001b[38;5;241m.\u001b[39m_drop_axis(labels, axis, level\u001b[38;5;241m=\u001b[39mlevel, errors\u001b[38;5;241m=\u001b[39merrors)\n\u001b[0;32m 4551\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m inplace:\n\u001b[0;32m 4552\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_update_inplace(obj)\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\core\\generic.py:4591\u001b[0m, in \u001b[0;36mNDFrame._drop_axis\u001b[1;34m(self, labels, axis, level, errors, only_slice)\u001b[0m\n\u001b[0;32m 4589\u001b[0m new_axis \u001b[38;5;241m=\u001b[39m axis\u001b[38;5;241m.\u001b[39mdrop(labels, level\u001b[38;5;241m=\u001b[39mlevel, errors\u001b[38;5;241m=\u001b[39merrors)\n\u001b[0;32m 4590\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m-> 4591\u001b[0m new_axis \u001b[38;5;241m=\u001b[39m axis\u001b[38;5;241m.\u001b[39mdrop(labels, errors\u001b[38;5;241m=\u001b[39merrors)\n\u001b[0;32m 4592\u001b[0m indexer \u001b[38;5;241m=\u001b[39m axis\u001b[38;5;241m.\u001b[39mget_indexer(new_axis)\n\u001b[0;32m 4594\u001b[0m \u001b[38;5;66;03m# Case for non-unique axis\u001b[39;00m\n\u001b[0;32m 4595\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\core\\indexes\\base.py:6699\u001b[0m, in \u001b[0;36mIndex.drop\u001b[1;34m(self, labels, errors)\u001b[0m\n\u001b[0;32m 6697\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m mask\u001b[38;5;241m.\u001b[39many():\n\u001b[0;32m 6698\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m errors \u001b[38;5;241m!=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mignore\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m-> 6699\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlist\u001b[39m(labels[mask])\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m not found in axis\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 6700\u001b[0m indexer \u001b[38;5;241m=\u001b[39m indexer[\u001b[38;5;241m~\u001b[39mmask]\n\u001b[0;32m 6701\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdelete(indexer)\n",
+ "\u001b[1;31mKeyError\u001b[0m: \"['event'] not found in axis\""
+ ]
+ }
+ ],
"source": [
"event_list = ['Snow', 'Fog', 'Rain', 'Thunderstorm']\n",
- "\n",
- "# Your code here\n",
- "\n",
- "\n",
- "# Print your new dataframe to check whether new columns have been created:\n",
- "\n",
- "austin_fixed"
+ "for event in event_list:\n",
+ " austin_fixed[event]=0\n",
+ " \n",
+ "austin_fixed.drop(columns=[\"event_rain\"], inplace=True)\n",
+ "austin_fixed.drop(columns=[\"event_snow\"], inplace=True)\n",
+ "austin_fixed.drop(columns=[\"event_fog\"], inplace=True)\n",
+ "austin_fixed.drop(columns=[\"event_thunderstorm\"] , inplace=True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 46,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Date | \n",
+ " TempHighF | \n",
+ " TempAvgF | \n",
+ " TempLowF | \n",
+ " DewPointHighF | \n",
+ " DewPointAvgF | \n",
+ " DewPointLowF | \n",
+ " HumidityHighPercent | \n",
+ " HumidityAvgPercent | \n",
+ " HumidityLowPercent | \n",
+ " ... | \n",
+ " VisibilityAvgMiles | \n",
+ " VisibilityLowMiles | \n",
+ " WindHighMPH | \n",
+ " WindAvgMPH | \n",
+ " WindGustMPH | \n",
+ " Events | \n",
+ " Snow | \n",
+ " Fog | \n",
+ " Rain | \n",
+ " Thunderstorm | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2013-12-21 | \n",
+ " 74 | \n",
+ " 60 | \n",
+ " 45 | \n",
+ " 67.0 | \n",
+ " 49.0 | \n",
+ " 43.0 | \n",
+ " 93.0 | \n",
+ " 75.0 | \n",
+ " 57.0 | \n",
+ " ... | \n",
+ " 7.0 | \n",
+ " 2.0 | \n",
+ " 20.0 | \n",
+ " 4.0 | \n",
+ " 31.0 | \n",
+ " Rain , Thunderstorm | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2013-12-22 | \n",
+ " 56 | \n",
+ " 48 | \n",
+ " 39 | \n",
+ " 43.0 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 93.0 | \n",
+ " 68.0 | \n",
+ " 43.0 | \n",
+ " ... | \n",
+ " 10.0 | \n",
+ " 5.0 | \n",
+ " 16.0 | \n",
+ " 6.0 | \n",
+ " 25.0 | \n",
+ " | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2013-12-23 | \n",
+ " 58 | \n",
+ " 45 | \n",
+ " 32 | \n",
+ " 31.0 | \n",
+ " 27.0 | \n",
+ " 23.0 | \n",
+ " 76.0 | \n",
+ " 52.0 | \n",
+ " 27.0 | \n",
+ " ... | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 8.0 | \n",
+ " 3.0 | \n",
+ " 12.0 | \n",
+ " | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 2013-12-24 | \n",
+ " 61 | \n",
+ " 46 | \n",
+ " 31 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 21.0 | \n",
+ " 89.0 | \n",
+ " 56.0 | \n",
+ " 22.0 | \n",
+ " ... | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 12.0 | \n",
+ " 4.0 | \n",
+ " 20.0 | \n",
+ " | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 2013-12-25 | \n",
+ " 58 | \n",
+ " 50 | \n",
+ " 41 | \n",
+ " 44.0 | \n",
+ " 40.0 | \n",
+ " 36.0 | \n",
+ " 86.0 | \n",
+ " 71.0 | \n",
+ " 56.0 | \n",
+ " ... | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 10.0 | \n",
+ " 2.0 | \n",
+ " 16.0 | \n",
+ " | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ " 0 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5 rows × 24 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Date TempHighF TempAvgF TempLowF DewPointHighF DewPointAvgF \\\n",
+ "0 2013-12-21 74 60 45 67.0 49.0 \n",
+ "1 2013-12-22 56 48 39 43.0 36.0 \n",
+ "2 2013-12-23 58 45 32 31.0 27.0 \n",
+ "3 2013-12-24 61 46 31 36.0 28.0 \n",
+ "4 2013-12-25 58 50 41 44.0 40.0 \n",
+ "\n",
+ " DewPointLowF HumidityHighPercent HumidityAvgPercent HumidityLowPercent \\\n",
+ "0 43.0 93.0 75.0 57.0 \n",
+ "1 28.0 93.0 68.0 43.0 \n",
+ "2 23.0 76.0 52.0 27.0 \n",
+ "3 21.0 89.0 56.0 22.0 \n",
+ "4 36.0 86.0 71.0 56.0 \n",
+ "\n",
+ " ... VisibilityAvgMiles VisibilityLowMiles WindHighMPH WindAvgMPH \\\n",
+ "0 ... 7.0 2.0 20.0 4.0 \n",
+ "1 ... 10.0 5.0 16.0 6.0 \n",
+ "2 ... 10.0 10.0 8.0 3.0 \n",
+ "3 ... 10.0 7.0 12.0 4.0 \n",
+ "4 ... 10.0 7.0 10.0 2.0 \n",
+ "\n",
+ " WindGustMPH Events Snow Fog Rain Thunderstorm \n",
+ "0 31.0 Rain , Thunderstorm 0 0 0 0 \n",
+ "1 25.0 0 0 0 0 \n",
+ "2 12.0 0 0 0 0 \n",
+ "3 20.0 0 0 0 0 \n",
+ "4 16.0 0 0 0 0 \n",
+ "\n",
+ "[5 rows x 24 columns]"
+ ]
+ },
+ "execution_count": 46,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "austin_fixed.head()"
]
},
{
@@ -446,11 +1929,15 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
- "# Your code here\n"
+ "event_list = ['Snow', 'Fog', 'Rain', 'Thunderstorm']\n",
+ "\n",
+ "# Loop over the events and create the corresponding columns\n",
+ "for event in event_list:\n",
+ " austin_fixed[event] = austin_fixed[\"Events\"].str.contains(event).astype(int)"
]
},
{
@@ -462,11 +1949,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 55,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Fog\n",
+ "0 1250\n",
+ "1 69\n",
+ "Name: count, dtype: int64"
+ ]
+ },
+ "execution_count": 55,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "# Your code here\n"
+ "austin_fixed.head(5)\n",
+ "austin_fixed[\"Fog\"].value_counts()"
]
},
{
@@ -478,11 +1980,11 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 56,
"metadata": {},
"outputs": [],
"source": [
- "# Your code here\n"
+ "austin_fixed.drop(columns=[\"Events\"], inplace=True)\n"
]
},
{
@@ -500,27 +2002,258 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here\n"
+ "execution_count": 66,
+ "metadata": {},
+ "outputs": [
+ {
+ "ename": "TypeError",
+ "evalue": "strptime() argument 1 must be str, not int",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[1;32mIn[66], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mdatetime\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m datetime\n\u001b[1;32m----> 3\u001b[0m austin_fixed[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDate\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m austin_fixed[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDate\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39mapply(\u001b[38;5;28;01mlambda\u001b[39;00m x: datetime\u001b[38;5;241m.\u001b[39mstrptime(x, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY-\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm-\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\u001b[38;5;241m.\u001b[39mtoordinal())\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\core\\series.py:4630\u001b[0m, in \u001b[0;36mSeries.apply\u001b[1;34m(self, func, convert_dtype, args, **kwargs)\u001b[0m\n\u001b[0;32m 4520\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mapply\u001b[39m(\n\u001b[0;32m 4521\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 4522\u001b[0m func: AggFuncType,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 4525\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[0;32m 4526\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m DataFrame \u001b[38;5;241m|\u001b[39m Series:\n\u001b[0;32m 4527\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 4528\u001b[0m \u001b[38;5;124;03m Invoke function on values of Series.\u001b[39;00m\n\u001b[0;32m 4529\u001b[0m \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 4628\u001b[0m \u001b[38;5;124;03m dtype: float64\u001b[39;00m\n\u001b[0;32m 4629\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m-> 4630\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m SeriesApply(\u001b[38;5;28mself\u001b[39m, func, convert_dtype, args, kwargs)\u001b[38;5;241m.\u001b[39mapply()\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\core\\apply.py:1025\u001b[0m, in \u001b[0;36mSeriesApply.apply\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1022\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mapply_str()\n\u001b[0;32m 1024\u001b[0m \u001b[38;5;66;03m# self.f is Callable\u001b[39;00m\n\u001b[1;32m-> 1025\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mapply_standard()\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\core\\apply.py:1076\u001b[0m, in \u001b[0;36mSeriesApply.apply_standard\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1074\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 1075\u001b[0m values \u001b[38;5;241m=\u001b[39m obj\u001b[38;5;241m.\u001b[39mastype(\u001b[38;5;28mobject\u001b[39m)\u001b[38;5;241m.\u001b[39m_values\n\u001b[1;32m-> 1076\u001b[0m mapped \u001b[38;5;241m=\u001b[39m lib\u001b[38;5;241m.\u001b[39mmap_infer(\n\u001b[0;32m 1077\u001b[0m values,\n\u001b[0;32m 1078\u001b[0m f,\n\u001b[0;32m 1079\u001b[0m convert\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconvert_dtype,\n\u001b[0;32m 1080\u001b[0m )\n\u001b[0;32m 1082\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(mapped) \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(mapped[\u001b[38;5;241m0\u001b[39m], ABCSeries):\n\u001b[0;32m 1083\u001b[0m \u001b[38;5;66;03m# GH#43986 Need to do list(mapped) in order to get treated as nested\u001b[39;00m\n\u001b[0;32m 1084\u001b[0m \u001b[38;5;66;03m# See also GH#25959 regarding EA support\u001b[39;00m\n\u001b[0;32m 1085\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m obj\u001b[38;5;241m.\u001b[39m_constructor_expanddim(\u001b[38;5;28mlist\u001b[39m(mapped), index\u001b[38;5;241m=\u001b[39mobj\u001b[38;5;241m.\u001b[39mindex)\n",
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\pandas\\_libs\\lib.pyx:2834\u001b[0m, in \u001b[0;36mpandas._libs.lib.map_infer\u001b[1;34m()\u001b[0m\n",
+ "Cell \u001b[1;32mIn[66], line 3\u001b[0m, in \u001b[0;36m\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mdatetime\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m datetime\n\u001b[1;32m----> 3\u001b[0m austin_fixed[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDate\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m austin_fixed[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDate\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39mapply(\u001b[38;5;28;01mlambda\u001b[39;00m x: datetime\u001b[38;5;241m.\u001b[39mstrptime(x, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY-\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm-\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\u001b[38;5;241m.\u001b[39mtoordinal())\n",
+ "\u001b[1;31mTypeError\u001b[0m: strptime() argument 1 must be str, not int"
+ ]
+ }
+ ],
+ "source": [
+ "from datetime import datetime\n",
+ "\n",
+ "austin_fixed[\"Date\"] = austin_fixed[\"Date\"].apply(lambda x: datetime.strptime(x, \"%Y-%m-%d\").toordinal())"
]
},
{
- "cell_type": "markdown",
- "metadata": {},
+ "cell_type": "code",
+ "execution_count": 70,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " Date | \n",
+ " TempHighF | \n",
+ " TempAvgF | \n",
+ " TempLowF | \n",
+ " DewPointHighF | \n",
+ " DewPointAvgF | \n",
+ " DewPointLowF | \n",
+ " HumidityHighPercent | \n",
+ " HumidityAvgPercent | \n",
+ " HumidityLowPercent | \n",
+ " SeaLevelPressureHighInches | \n",
+ " SeaLevelPressureAvgInches | \n",
+ " SeaLevelPressureLowInches | \n",
+ " VisibilityHighMiles | \n",
+ " VisibilityAvgMiles | \n",
+ " VisibilityLowMiles | \n",
+ " WindHighMPH | \n",
+ " WindAvgMPH | \n",
+ " WindGustMPH | \n",
+ " Events | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 2013-12-21 | \n",
+ " 74 | \n",
+ " 60 | \n",
+ " 45 | \n",
+ " 67.0 | \n",
+ " 49.0 | \n",
+ " 43.0 | \n",
+ " 93.0 | \n",
+ " 75.0 | \n",
+ " 57.0 | \n",
+ " 29.86 | \n",
+ " 29.68 | \n",
+ " 29.59 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 2.0 | \n",
+ " 20.0 | \n",
+ " 4.0 | \n",
+ " 31.0 | \n",
+ " Rain , Thunderstorm | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2013-12-22 | \n",
+ " 56 | \n",
+ " 48 | \n",
+ " 39 | \n",
+ " 43.0 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 93.0 | \n",
+ " 68.0 | \n",
+ " 43.0 | \n",
+ " 30.41 | \n",
+ " 30.13 | \n",
+ " 29.87 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 5.0 | \n",
+ " 16.0 | \n",
+ " 6.0 | \n",
+ " 25.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 2013-12-23 | \n",
+ " 58 | \n",
+ " 45 | \n",
+ " 32 | \n",
+ " 31.0 | \n",
+ " 27.0 | \n",
+ " 23.0 | \n",
+ " 76.0 | \n",
+ " 52.0 | \n",
+ " 27.0 | \n",
+ " 30.56 | \n",
+ " 30.49 | \n",
+ " 30.41 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 8.0 | \n",
+ " 3.0 | \n",
+ " 12.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 2013-12-24 | \n",
+ " 61 | \n",
+ " 46 | \n",
+ " 31 | \n",
+ " 36.0 | \n",
+ " 28.0 | \n",
+ " 21.0 | \n",
+ " 89.0 | \n",
+ " 56.0 | \n",
+ " 22.0 | \n",
+ " 30.56 | \n",
+ " 30.45 | \n",
+ " 30.30 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 12.0 | \n",
+ " 4.0 | \n",
+ " 20.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 2013-12-25 | \n",
+ " 58 | \n",
+ " 50 | \n",
+ " 41 | \n",
+ " 44.0 | \n",
+ " 40.0 | \n",
+ " 36.0 | \n",
+ " 86.0 | \n",
+ " 71.0 | \n",
+ " 56.0 | \n",
+ " 30.41 | \n",
+ " 30.33 | \n",
+ " 30.27 | \n",
+ " 10.0 | \n",
+ " 10.0 | \n",
+ " 7.0 | \n",
+ " 10.0 | \n",
+ " 2.0 | \n",
+ " 16.0 | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " Date TempHighF TempAvgF TempLowF DewPointHighF DewPointAvgF \\\n",
+ "0 2013-12-21 74 60 45 67.0 49.0 \n",
+ "1 2013-12-22 56 48 39 43.0 36.0 \n",
+ "2 2013-12-23 58 45 32 31.0 27.0 \n",
+ "3 2013-12-24 61 46 31 36.0 28.0 \n",
+ "4 2013-12-25 58 50 41 44.0 40.0 \n",
+ "\n",
+ " DewPointLowF HumidityHighPercent HumidityAvgPercent HumidityLowPercent \\\n",
+ "0 43.0 93.0 75.0 57.0 \n",
+ "1 28.0 93.0 68.0 43.0 \n",
+ "2 23.0 76.0 52.0 27.0 \n",
+ "3 21.0 89.0 56.0 22.0 \n",
+ "4 36.0 86.0 71.0 56.0 \n",
+ "\n",
+ " SeaLevelPressureHighInches SeaLevelPressureAvgInches \\\n",
+ "0 29.86 29.68 \n",
+ "1 30.41 30.13 \n",
+ "2 30.56 30.49 \n",
+ "3 30.56 30.45 \n",
+ "4 30.41 30.33 \n",
+ "\n",
+ " SeaLevelPressureLowInches VisibilityHighMiles VisibilityAvgMiles \\\n",
+ "0 29.59 10.0 7.0 \n",
+ "1 29.87 10.0 10.0 \n",
+ "2 30.41 10.0 10.0 \n",
+ "3 30.30 10.0 10.0 \n",
+ "4 30.27 10.0 10.0 \n",
+ "\n",
+ " VisibilityLowMiles WindHighMPH WindAvgMPH WindGustMPH \\\n",
+ "0 2.0 20.0 4.0 31.0 \n",
+ "1 5.0 16.0 6.0 25.0 \n",
+ "2 10.0 8.0 3.0 12.0 \n",
+ "3 7.0 12.0 4.0 20.0 \n",
+ "4 7.0 10.0 2.0 16.0 \n",
+ "\n",
+ " Events \n",
+ "0 Rain , Thunderstorm \n",
+ "1 \n",
+ "2 \n",
+ "3 \n",
+ "4 "
+ ]
+ },
+ "execution_count": 70,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
- "#### Print `austin_fixed` to check your `Date` column."
+ "austin_fixed.head(5)"
]
},
{
- "cell_type": "code",
- "execution_count": null,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [],
"source": [
- "austin_fixed.head(5)"
+ "#### Print `austin_fixed` to check your `Date` column."
]
},
{
@@ -577,11 +2310,15 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 72,
"metadata": {},
"outputs": [],
"source": [
- "# Your code here:\n"
+ "# Your code here:\n",
+ "from sklearn.model_selection import train_test_split\n",
+ "\n",
+ "X=austin_fixed.drop(columns=[\"TempAvgF\"]) \n",
+ "y= austin_fixed[\"TempAvgF\"] "
]
},
{
@@ -593,7 +2330,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
@@ -612,11 +2349,12 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
- "#Your code here:\n"
+ "#Your code here:\n",
+ "X_train, X_test, y_train, y_test=train_test_split(X, y, test_size=0.20, random_state=0)"
]
},
{
@@ -641,7 +2379,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
@@ -657,7 +2395,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
@@ -673,7 +2411,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
@@ -683,7 +2421,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -697,7 +2435,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.9"
+ "version": "3.11.5"
}
},
"nbformat": 4,