Ajout commentaire

parent 57113836
...@@ -57,17 +57,48 @@ ...@@ -57,17 +57,48 @@
"La première ligne du fichier CSV est un commentaire, que nous ignorons en précisant `skiprows=1`." "La première ligne du fichier CSV est un commentaire, que nous ignorons en précisant `skiprows=1`."
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Changement du code* : les données ont été écrites au format csv. Le code vérifie que les données sont toujours présentes et les lit en priorité. Sinon, il va les chercher sur l'URL."
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"existe\n"
]
},
{
"data": {
"text/plain": [
"1883"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"raw_data = pd.read_csv(data_url, skiprows=1)\n", "#raw_data = pd.read_csv(data_url, skiprows=1)\n",
"#raw_data\n", "#raw_data\n",
"raw_data.to_csv('incidence-PAY-3.csv')\n", "#raw_data.to_csv('incidence-PAY-3.csv')\n",
"#with open('incidence-PAY-3.csv', 'w') as file:\n", "import os\n",
"# csv.writer(file)" "if os.path.isfile('incidence-PAY-3.csv'):\n",
" raw_data = pd.read_csv('incidence-PAY-3.csv', skiprows = 1)\n",
" print('existe')\n",
"else:\n",
" print(\"n'existe pas\")\n",
" raw_data = pd.read_csv(data_url, skiprows = 1)\n",
"len(raw_data)"
] ]
}, },
{ {
...@@ -79,9 +110,72 @@ ...@@ -79,9 +110,72 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [], "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>0</th>\n",
" <th>202049</th>\n",
" <th>3</th>\n",
" <th>13273</th>\n",
" <th>10162.0</th>\n",
" <th>16384.0</th>\n",
" <th>20</th>\n",
" <th>15.0</th>\n",
" <th>25.0</th>\n",
" <th>FR</th>\n",
" <th>France</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1646</th>\n",
" <td>1647</td>\n",
" <td>198919</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>FR</td>\n",
" <td>France</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 202049 3 13273 10162.0 16384.0 20 15.0 25.0 FR France\n",
"1646 1647 198919 3 0 NaN NaN 0 NaN NaN FR France"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"raw_data[raw_data.isnull().any(axis=1)]" "raw_data[raw_data.isnull().any(axis=1)]"
] ]
......
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