|
87 | 87 | "cell_type": "markdown",
|
88 | 88 | "metadata": {},
|
89 | 89 | "source": [
|
90 |
| - "### Step 2. Import the dataset from this [address](https://github.com/guipsamora/pandas_exercises/blob/master/Stats/Wind_Stats/wind.data)" |
| 90 | + "### Step 2. Import the dataset from this [address](https://github.com/guipsamora/pandas_exercises/blob/master/06_Stats/Wind_Stats/wind.data)" |
91 | 91 | ]
|
92 | 92 | },
|
93 | 93 | {
|
|
235 | 235 | ],
|
236 | 236 | "source": [
|
237 | 237 | "# parse_dates gets 0, 1, 2 columns and parses them as the index\n",
|
238 |
| - "data = pd.read_table(\"wind.data\", sep = \"\\s+\", parse_dates = [[0,1,2]]) \n", |
| 238 | + "data_url = 'https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/06_Stats/Wind_Stats/wind.data'\n", |
| 239 | + "data = pd.read_table(data_url, sep = \"\\s+\", parse_dates = [[0,1,2]]) \n", |
239 | 240 | "data.head()"
|
240 | 241 | ]
|
241 | 242 | },
|
|
848 | 849 | "data['year'] = data['date'].apply(lambda date: date.year)\n",
|
849 | 850 | "data['day'] = data['date'].apply(lambda date: date.day)\n",
|
850 | 851 | "\n",
|
851 |
| - "# gets all value from the month 1 and assign to janyary_winds\n", |
| 852 | + "# gets all value from the month 1 and assign to january_winds\n", |
852 | 853 | "january_winds = data.query('month == 1')\n",
|
853 | 854 | "\n",
|
854 | 855 | "# gets the mean from january_winds, using .loc to not print the mean of month, year and day\n",
|
|
4209 | 4210 | ],
|
4210 | 4211 | "source": [
|
4211 | 4212 | "# call data again but this time don't use parse_dates\n",
|
4212 |
| - "wind_data = pd.read_table(\"wind.data\", sep = \"\\s+\") \n", |
| 4213 | + "data_url = 'https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/06_Stats/Wind_Stats/wind.data'\n", |
| 4214 | + "wind_data = pd.read_table(data_url, sep = \"\\s+\") \n", |
4213 | 4215 | "\n",
|
4214 | 4216 | "# compute the month number for each day in the dataset, there are in total 216 months\n",
|
4215 | 4217 | "wind_data['months_num'] = (wind_data.iloc[:, 0] - 61) * 12 + wind_data.iloc[:, 1]\n",
|
|
4603 | 4605 | "weekly = data.resample('W').agg(['min','max','mean','std'])\n",
|
4604 | 4606 | "\n",
|
4605 | 4607 | "# slice it for the first 52 weeks and locations\n",
|
4606 |
| - "weekly.ix[1:53, \"RPT\":\"MAL\"].head(10)" |
| 4608 | + "weekly.loc[weekly.index[1:53], \"RPT\":\"MAL\"] .head(10)" |
4607 | 4609 | ]
|
4608 | 4610 | }
|
4609 | 4611 | ],
|
|
0 commit comments