diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 68b3762..5d0d973 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -12,11 +12,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "#Import your libraries\n" + "# 📚 Basic Libraries\n", + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "# 📊 Visualizations\n", + "import matplotlib.pyplot as plt\n", + "import seaborn as sns\n", + "import plotly.express as px\n", + "import plotly.graph_objects as go\n", + "\n", + "# 🤖 Machine Learning\n", + "from sklearn.model_selection import train_test_split\n", + "from sklearn.linear_model import LinearRegression\n", + "from sklearn.metrics import r2_score, mean_squared_error, mean_absolute_error" ] }, { @@ -36,13 +49,330 @@ "#### First, import it into a data frame called `austin`. " ] }, + { + "cell_type": "code", + "execution_count": 2, + "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", + " \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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
DateTempHighFTempAvgFTempLowFDewPointHighFDewPointAvgFDewPointLowFHumidityHighPercentHumidityAvgPercentHumidityLowPercent...SeaLevelPressureAvgInchesSeaLevelPressureLowInchesVisibilityHighMilesVisibilityAvgMilesVisibilityLowMilesWindHighMPHWindAvgMPHWindGustMPHPrecipitationSumInchesEvents
02013-12-21746045674943937557...29.6829.591072204310.46Rain , Thunderstorm
12013-12-22564839433628936843...30.1329.8710105166250
22013-12-23584532312723765227...30.4930.4110101083120
32013-12-24614631362821895622...30.4530.310107124200
42013-12-25585041444036867156...30.3330.271010710216T
\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": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df = pd.read_csv('austin_weather.csv')\n", + "df.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1319, 21)" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.shape" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "df.columns = df.columns.str.lower().str.replace(\" \", \"_\")\n", + "df.head(0)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "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", + "
DateTempHighFTempAvgFTempLowFDewPointHighFDewPointAvgFDewPointLowFHumidityHighPercentHumidityAvgPercentHumidityLowPercent...SeaLevelPressureAvgInchesSeaLevelPressureLowInchesVisibilityHighMilesVisibilityAvgMilesVisibilityLowMilesWindHighMPHWindAvgMPHWindGustMPHPrecipitationSumInchesEvents
\n", + "

0 rows × 21 columns

\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [Date, TempHighF, TempAvgF, TempLowF, DewPointHighF, DewPointAvgF, DewPointLowF, HumidityHighPercent, HumidityAvgPercent, HumidityLowPercent, SeaLevelPressureHighInches, SeaLevelPressureAvgInches, SeaLevelPressureLowInches, VisibilityHighMiles, VisibilityAvgMiles, VisibilityLowMiles, WindHighMPH, WindAvgMPH, WindGustMPH, PrecipitationSumInches, Events]\n", + "Index: []\n", + "\n", + "[0 rows x 21 columns]" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.head(0)" ] }, { @@ -57,11 +387,43 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Date object\n", + "TempHighF int64\n", + "TempAvgF int64\n", + "TempLowF int64\n", + "DewPointHighF object\n", + "DewPointAvgF object\n", + "DewPointLowF object\n", + "HumidityHighPercent object\n", + "HumidityAvgPercent object\n", + "HumidityLowPercent object\n", + "SeaLevelPressureHighInches object\n", + "SeaLevelPressureAvgInches object\n", + "SeaLevelPressureLowInches object\n", + "VisibilityHighMiles object\n", + "VisibilityAvgMiles object\n", + "VisibilityLowMiles object\n", + "WindHighMPH object\n", + "WindAvgMPH object\n", + "WindGustMPH object\n", + "PrecipitationSumInches object\n", + "Events object\n", + "dtype: object" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.dtypes\n" ] }, { @@ -113,20 +475,79 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Date 1319\n", + "TempHighF 74\n", + "TempAvgF 64\n", + "TempLowF 61\n", + "DewPointHighF 64\n", + "DewPointAvgF 66\n", + "DewPointLowF 73\n", + "HumidityHighPercent 58\n", + "HumidityAvgPercent 69\n", + "HumidityLowPercent 82\n", + "SeaLevelPressureHighInches 105\n", + "SeaLevelPressureAvgInches 101\n", + "SeaLevelPressureLowInches 105\n", + "VisibilityHighMiles 5\n", + "VisibilityAvgMiles 10\n", + "VisibilityLowMiles 12\n", + "WindHighMPH 22\n", + "WindAvgMPH 13\n", + "WindGustMPH 37\n", + "PrecipitationSumInches 114\n", + "Events 9\n", + "dtype: int64" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "df.nunique()" ] }, { "cell_type": "code", - "execution_count": null, + "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": [ + "df['DewPointAvgF'].unique()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ - "# Your observation here\n" + "# Your observation here. They are treated as object because we do have \" \". \n" ] }, { @@ -140,7 +561,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -153,11 +574,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Your code here\n", + "for col in wrong_type_columns:\n", + " df[col] = pd.to_numeric(df[col], errors='coerce')" ] }, { @@ -169,11 +592,43 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Date object\n", + "TempHighF int64\n", + "TempAvgF int64\n", + "TempLowF int64\n", + "DewPointHighF float64\n", + "DewPointAvgF float64\n", + "DewPointLowF float64\n", + "HumidityHighPercent float64\n", + "HumidityAvgPercent float64\n", + "HumidityLowPercent float64\n", + "SeaLevelPressureHighInches float64\n", + "SeaLevelPressureAvgInches float64\n", + "SeaLevelPressureLowInches float64\n", + "VisibilityHighMiles float64\n", + "VisibilityAvgMiles float64\n", + "VisibilityLowMiles float64\n", + "WindHighMPH float64\n", + "WindAvgMPH float64\n", + "WindGustMPH float64\n", + "PrecipitationSumInches float64\n", + "Events object\n", + "dtype: object" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.dtypes\n" ] }, { @@ -200,11 +655,73 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, + "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": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.isna().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# Assign the dataframes with missing values into a variable. \n", + "missing_values = df[df.isnull().any(axis=1)]" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "136" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(missing_values)" ] }, { @@ -233,11 +750,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1319" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Total number of rows. \n", + "df.shape[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "136" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(missing_values)" ] }, { @@ -249,11 +798,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "10.31" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "round(len(missing_values) / df.shape[0] * 100, 2)" ] }, { @@ -267,11 +827,43 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here\n" + "execution_count": 18, + "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": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.isna().sum()" ] }, { @@ -283,11 +875,42 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "124" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "df['PrecipitationSumInches'].isna().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "9.401061410159212" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df['PrecipitationSumInches'].isna().sum() / df.shape[0] * 100" ] }, { @@ -309,16 +932,51 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ - "# Your code here \n", - "\n", - "\n", - "# Print `austin` to confirm the column is indeed removed\n", - "\n", - "austin" + "df.drop('PrecipitationSumInches', axis=1, inplace=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "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", + "Events 0\n", + "dtype: int64" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.isna().sum()" ] }, { @@ -336,11 +994,410 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/var/folders/bs/hzz4qdm57z9cct0t_9rdynfr0000gn/T/ipykernel_1911/1226798285.py:2: FutureWarning: DataFrame.interpolate with object dtype is deprecated and will raise in a future version. Call obj.infer_objects(copy=False) before interpolating instead.\n", + " austin_fixed = df.interpolate(inplace=False)\n" + ] + }, + { + "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", + " \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", + " \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", + " \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", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
DateTempHighFTempAvgFTempLowFDewPointHighFDewPointAvgFDewPointLowFHumidityHighPercentHumidityAvgPercentHumidityLowPercentSeaLevelPressureHighInchesSeaLevelPressureAvgInchesSeaLevelPressureLowInchesVisibilityHighMilesVisibilityAvgMilesVisibilityLowMilesWindHighMPHWindAvgMPHWindGustMPHEvents
02013-12-2174604567.049.043.093.075.057.029.8629.6829.5910.07.02.020.04.031.0Rain , Thunderstorm
12013-12-2256483943.036.028.093.068.043.030.4130.1329.8710.010.05.016.06.025.0
22013-12-2358453231.027.023.076.052.027.030.5630.4930.4110.010.010.08.03.012.0
32013-12-2461463136.028.021.089.056.022.030.5630.4530.3010.010.07.012.04.020.0
42013-12-2558504144.040.036.086.071.056.030.4130.3330.2710.010.07.010.02.016.0
...............................................................
13142017-07-27103897571.067.061.082.054.025.030.0429.9729.8810.010.010.012.05.021.0
13152017-07-28105917671.064.055.087.054.020.029.9729.9029.8110.010.010.014.05.020.0
13162017-07-29107927772.064.055.082.051.019.029.9129.8629.7910.010.010.012.04.017.0
13172017-07-30106937970.068.063.069.048.027.029.9629.9129.8710.010.010.013.04.020.0
13182017-07-3199887766.061.054.064.043.022.030.0429.9729.9110.010.010.012.04.020.0
\n", + "

1319 rows × 20 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", + "1314 2017-07-27 103 89 75 71.0 67.0 \n", + "1315 2017-07-28 105 91 76 71.0 64.0 \n", + "1316 2017-07-29 107 92 77 72.0 64.0 \n", + "1317 2017-07-30 106 93 79 70.0 68.0 \n", + "1318 2017-07-31 99 88 77 66.0 61.0 \n", + "\n", + " DewPointLowF HumidityHighPercent HumidityAvgPercent \\\n", + "0 43.0 93.0 75.0 \n", + "1 28.0 93.0 68.0 \n", + "2 23.0 76.0 52.0 \n", + "3 21.0 89.0 56.0 \n", + "4 36.0 86.0 71.0 \n", + "... ... ... ... \n", + "1314 61.0 82.0 54.0 \n", + "1315 55.0 87.0 54.0 \n", + "1316 55.0 82.0 51.0 \n", + "1317 63.0 69.0 48.0 \n", + "1318 54.0 64.0 43.0 \n", + "\n", + " HumidityLowPercent SeaLevelPressureHighInches \\\n", + "0 57.0 29.86 \n", + "1 43.0 30.41 \n", + "2 27.0 30.56 \n", + "3 22.0 30.56 \n", + "4 56.0 30.41 \n", + "... ... ... \n", + "1314 25.0 30.04 \n", + "1315 20.0 29.97 \n", + "1316 19.0 29.91 \n", + "1317 27.0 29.96 \n", + "1318 22.0 30.04 \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", + "1314 29.97 29.88 \n", + "1315 29.90 29.81 \n", + "1316 29.86 29.79 \n", + "1317 29.91 29.87 \n", + "1318 29.97 29.91 \n", + "\n", + " VisibilityHighMiles VisibilityAvgMiles VisibilityLowMiles \\\n", + "0 10.0 7.0 2.0 \n", + "1 10.0 10.0 5.0 \n", + "2 10.0 10.0 10.0 \n", + "3 10.0 10.0 7.0 \n", + "4 10.0 10.0 7.0 \n", + "... ... ... ... \n", + "1314 10.0 10.0 10.0 \n", + "1315 10.0 10.0 10.0 \n", + "1316 10.0 10.0 10.0 \n", + "1317 10.0 10.0 10.0 \n", + "1318 10.0 10.0 10.0 \n", + "\n", + " WindHighMPH WindAvgMPH WindGustMPH Events \n", + "0 20.0 4.0 31.0 Rain , Thunderstorm \n", + "1 16.0 6.0 25.0 \n", + "2 8.0 3.0 12.0 \n", + "3 12.0 4.0 20.0 \n", + "4 10.0 2.0 16.0 \n", + "... ... ... ... ... \n", + "1314 12.0 5.0 21.0 \n", + "1315 14.0 5.0 20.0 \n", + "1316 12.0 4.0 17.0 \n", + "1317 13.0 4.0 20.0 \n", + "1318 12.0 4.0 20.0 \n", + "\n", + "[1319 rows x 20 columns]" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "austin_fixed = df.interpolate(inplace=False)\n", + "austin_fixed" ] }, { @@ -352,11 +1409,83 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 24, + "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": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "austin_fixed.isna().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "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", + "Events 0\n", + "dtype: int64" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df.isna().sum()" ] }, { @@ -377,11 +1506,33 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Your code here:\n" + "execution_count": 26, + "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": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Your code here:\n", + "austin_fixed['Events'].value_counts()" ] }, { @@ -395,11 +1546,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, "outputs": [], "source": [ - "# Your answer:\n" + "# Your answer:\n", + "# The largest number of events in a single day is 3. Fog, Rain and Storm. " ] }, { @@ -419,6 +1571,7 @@ "metadata": {}, "outputs": [], "source": [ + "# I could not make it work. It gaves me 0 when it had data on it. ∫\n", "event_list = ['Snow', 'Fog', 'Rain', 'Thunderstorm']\n", "\n", "# Your code here\n", @@ -683,7 +1836,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "base", "language": "python", "name": "python3" }, @@ -697,7 +1850,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.9" + "version": "3.12.4" } }, "nbformat": 4,