Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit eaba0705 authored by Loic Huder's avatar Loic Huder
Browse files

Added multiple choices for step 1

parent f53b9a93
......@@ -63,30 +63,34 @@
}
},
"source": [
"# Step 1.1: load data\n",
"# Step 1: load data\n",
"\n",
"Write a script with a function `load_data()` that\n",
" - open the file\n",
" - load data in a dictionary (global variable) with these structure\n",
" \n",
" ```python\n",
" {'Date': [wind,temperature,humidity,rainfall]}\n",
" ```\n",
"\n",
" For example\n",
"\n",
" ```python\n",
" {\n",
" '2016-01-01T01': [2.0,283.75,94,0.2],\n",
" '2016-01-01T04': [2.2,283.95,91,0.2]\n",
" }\n",
" ```\n",
" - load data in one of the following structures (more details below):\n",
" - 1.1 Single dictionnary\n",
" - 1.2 Multiple structures\n",
" - 1.3 Class instance (object-oriented)\n",
"\n",
"## 1.1: Single dictionnary (pres07)\n",
"Load in the data in a single dictionnary of this structure:\n",
"```python\n",
"{'Date': [wind,temperature,humidity,rainfall]}\n",
"```\n",
"\n",
"For example\n",
"```python\n",
"{\n",
" '2016-01-01T01': [2.0,283.75,94,0.2],\n",
" '2016-01-01T04': [2.2,283.95,91,0.2]\n",
"}\n",
"```\n",
" \n",
"In this case, we can consider YYYY-MM-DDTHH as the key for the station dictionary.\n",
"\n",
"Split each line and extract data.\n",
"\n",
"## hint\n",
"#### Hint\n",
"You can use the method *split* from the str class.\n"
]
},
......@@ -113,6 +117,40 @@
"print(l)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.2: Multiple structures (pres07)\n",
"Load the data in multiple dictionnaries or lists (one per field).\n",
"#### Example for dictionnaries:\n",
"You can use the following structure\n",
"```python3\n",
"wind = {'Date1': wind_value1, 'Date2: wind_value2, ...}\n",
"temperature = {'Date1': temperature1, 'Date2: temperature2, ...}\n",
"...\n",
"```\n",
"#### Example for lists:\n",
"You can use the following structure\n",
"```python3\n",
"dates = ['Date1', 'Date2', ...]\n",
"wind = [wind_value1, wind_value2, ...]\n",
"temperature = [temperature1, temperature2, ...]\n",
"...\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1.3: Class instance (pres08)\n",
"Load the data in an instance of a class `WeatherStation` that you will define yourself. `load_data()` can therefore be a method of this class.\n",
"\n",
"#### Hint :\n",
"This is very similar as 1.2. The only difference is that the structures storing the data are attributes of a class."
]
},
{
"cell_type": "markdown",
"metadata": {
......@@ -121,7 +159,7 @@
}
},
"source": [
"# Step 1.2: Compute max temperature and average temperature for the station\n",
"# Step 2: Compute max temperature and average temperature for the station\n",
"\n",
"Write 2 functions `get_max_temperature()` and `get_average_temperature()` that:\n",
"\n",
......@@ -137,7 +175,7 @@
}
},
"source": [
"# Step 1.3: Compute sum of the rainfall for one station\n",
"# Step 3: Compute sum of the rainfall for one station\n",
"\n",
"Write 1 function `get_sum_rainfall()` that sum the rainfall.\n",
"\n",
......@@ -154,14 +192,14 @@
}
},
"source": [
"# Step 1.4: Search max period without rainfall\n",
"# Step 4: Search max period without rainfall\n",
"\n",
"Write 1 function `period_without_rainfall()`\n",
"\n",
"- return the beginning date, the ending date and the number of days without rainfall\n",
"\n",
"## Hint\n",
"This is the syntax to return more than 1 value in a function:\n",
"This is the syntax to return multiple values in a function:\n",
"\n",
"```\n",
"return date_min, date_max, period_max / 8\n",
......@@ -176,7 +214,7 @@
}
},
"source": [
"# Step 1.5: How many hours with humidity rate < 60\n",
"# Step 5: How many hours with humidity rate < 60\n",
"\n",
"Write 1 function `get_hours_humidity(rate)`\n",
"\n",
......@@ -199,7 +237,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [
{
......@@ -213,7 +251,7 @@
"source": [
"import pandas\n",
"\n",
"df = pandas.read_table(\n",
"df = pandas.read_csv(\n",
" '../TP/TP1_MeteoData/data/synop-2016.csv', sep=',', header=0)\n",
"\n",
"# print(df.columns)\n",
......@@ -251,7 +289,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.6"
"version": "3.6.7"
}
},
"nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment