début de l'exercice sur le CO2

parent 7f077e40
This diff is collapsed.
{ {
"cells": [], "cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Concentration de CO2 dans l'atmosphère depuis 1958\n",
"\n",
"On s'intéresse à la concentration en CO2 au cours du temps depuis 1958; les données sont disponibles sur le site web [scrippsco2.ucsd.edu](https://scrippsco2.ucsd.edu/data/atmospheric_co2/primary_mlo_co2_record.html)\n",
"\n",
"Commençons par importer les bibliothèques nécessaires à l'analyse"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import isoweek"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Chargeons à présent les données"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"def skiprows(x):\n",
" return x < 62 or x in [63,64]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Données disponibles en local, téléchargement en cours\n"
]
}
],
"source": [
"data_url = \"https://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/in_situ_co2/monthly/monthly_in_situ_co2_mlo.csv\"\n",
"data_path = \"./monthly_in_situ_co2_mlo.csv\"\n",
"\n",
"try:\n",
" data = pd.read_csv(data_path)\n",
" print(\"Données disponibles en local, téléchargement en cours\")\n",
"except FileNotFoundError as e:\n",
" print(\"Données non disponibles, téléchargement...\")\n",
" data = pd.read_csv(data_url,skiprows=skiprows)\n",
" data.to_csv(data_path)\n",
" print(\"Téléchargement et enregistrement terminé\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",
...@@ -16,10 +92,9 @@ ...@@ -16,10 +92,9 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.3" "version": "3.6.4"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 2 "nbformat_minor": 2
} }
This diff is collapsed.
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