Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
57e92ddd8e047446b30777d5b69846d1
mooc-rr
Commits
4dcebe64
Commit
4dcebe64
authored
Feb 12, 2023
by
57e92ddd8e047446b30777d5b69846d1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
83d79dd3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
199 additions
and
0 deletions
+199
-0
exercice.ipynb
module3/exo3/exercice.ipynb
+199
-0
No files found.
module3/exo3/exercice.ipynb
View file @
4dcebe64
...
...
@@ -7,6 +7,205 @@
"# Sujet 1 : Concentration de CO2 dans l'atmosphère depuis 1958"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import isoweek\n",
"\n",
"# set diagram sizes\n",
"# print(plt.rcParams['figure.dpi']) # default = 72\n",
"# print(plt.rcParams['figure.figsize']) # default = 6.0, 4.0\n",
"# plt.rcParams['figure.dpi'] = 100\n",
"plt.rcParams['figure.figsize'] = [12.0, 4.0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Les données sont disponibles sur le site Web de l'[institut Scripps. ](https://scrippsco2.ucsd.edu/data/atmospheric_co2/primary_mlo_co2_record.html)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>value</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1958-03-29</td>\n",
" <td>316.19</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1958-04-05</td>\n",
" <td>317.31</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1958-04-12</td>\n",
" <td>317.69</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1958-04-19</td>\n",
" <td>317.58</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1958-04-26</td>\n",
" <td>316.48</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" date value\n",
"0 1958-03-29 316.19\n",
"1 1958-04-05 317.31\n",
"2 1958-04-12 317.69\n",
"3 1958-04-19 317.58\n",
"4 1958-04-26 316.48"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# récolte le 12/02\n",
"data_url = \"https://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/in_situ_co2/weekly/weekly_in_situ_co2_mlo.csv\"\n",
"data = pd.read_csv(data_url, encoding = 'utf-8', comment='\"', names=[\"date\", \"value\"])\n",
"data.head(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Contrôle Qualité\n",
"### Recherche des lignes sans donnée"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>value</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [date, value]\n",
"Index: []"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[data.isnull().any(axis=1)]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Il ne manque aucune donnée.\n",
"\n",
"### Vérification des écarts entre les données\n",
"On attend un écart de 7 jours entre chaque mesure."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data['timestamp'] = [ pd.to_datetime(d) for d in data['date'] ]\n",
"sorted_data = data.set_index('timestamp').sort_index()\n",
"sorted_data.head(5)\n",
"# for row1, row2 in zip(sorted_data[:-1], sorted_data[1:]):\n",
"# delta = (row2['timestamp'] - row1['timestamp']).days\n",
"# if delta != 7:\n",
"# print(row1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"l_index = sorted_data.index\n",
"l_index.head(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment