Nouvelle façon de passer de la base de donnée vers xlsx

This commit is contained in:
Bertrand Benjamin 2018-04-21 18:30:09 +03:00
parent dd4ff53182
commit 48380ca715

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 2,
"metadata": {
"collapsed": true
},
@ -13,20 +13,19 @@
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"from repytex.tools.evaluation import Evaluation\n",
"from repytex.tools.sqlite_getters import all_ev_description\n",
"from repytex.worksheets.worksheet import pull_datas\n",
"import pandas as pd\n",
"import numpy as np\n",
"import sqlite3"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"metadata": {
"collapsed": true
},
@ -37,7 +36,177 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'evaluation': id name term t_id\n",
" 0 1 DS1 mise en jambe 1 1,\n",
" 'exercises': id name eval_id date comment\n",
" 0 1 1 - Prendre la température 1 2017-09-05 00:00:00.000000 \n",
" 1 2 2 - Maladroite! 1 2017-09-05 00:00:00.000000 ,\n",
" 'question_scores': id question_id student_id value\n",
" 0 1 1 1 1\n",
" 1 2 2 1 2\n",
" 2 3 3 1 .\n",
" 3 4 1 2 2\n",
" 4 5 2 2 2\n",
" 5 6 3 2 1\n",
" 6 7 1 3 3\n",
" 7 8 2 3 0\n",
" 8 9 3 3 0\n",
" 9 10 1 4 3\n",
" 10 11 2 4 3\n",
" 11 12 3 4 0\n",
" 12 13 1 5 1\n",
" 13 14 2 5 2\n",
" 14 15 3 5 .\n",
" 15 16 1 6 3\n",
" 16 17 2 6 2\n",
" 17 18 3 6 0\n",
" 18 19 1 7 2\n",
" 19 20 2 7 2\n",
" 20 21 3 7 2\n",
" 21 22 1 9 2\n",
" 22 23 2 9 1\n",
" 23 24 3 9 2\n",
" 24 25 1 8 3\n",
" 25 26 2 8 1\n",
" 26 27 3 8 .\n",
" 27 28 1 10 1\n",
" 28 29 2 10 2\n",
" 29 30 3 10 0\n",
" .. ... ... ... ...\n",
" 178 803 4 21 .\n",
" 179 804 5 21 .\n",
" 180 805 6 21 .\n",
" 181 806 7 21 .\n",
" 182 807 8 21 .\n",
" 183 808 4 22 0\n",
" 184 809 5 22 .\n",
" 185 810 6 22 .\n",
" 186 811 7 22 .\n",
" 187 812 8 22 .\n",
" 188 813 4 23 3\n",
" 189 814 5 23 1\n",
" 190 815 6 23 1\n",
" 191 816 7 23 1\n",
" 192 817 8 23 1\n",
" 193 818 4 25 .\n",
" 194 819 5 25 .\n",
" 195 820 6 25 .\n",
" 196 821 7 25 .\n",
" 197 822 8 25 1\n",
" 198 823 4 24 3\n",
" 199 824 5 24 3\n",
" 200 825 6 24 3\n",
" 201 826 7 24 2\n",
" 202 827 8 24 2\n",
" 203 828 4 26 3\n",
" 204 829 5 26 3\n",
" 205 830 6 26 3\n",
" 206 831 7 26 3\n",
" 207 832 8 26 3\n",
" \n",
" [200 rows x 4 columns],\n",
" 'questions': id name score_rate is_leveled exercise_id competence domain \\\n",
" 0 1 1 0 1 1 Cher Grandeurs \n",
" 1 2 2 0 1 1 Cal Grandeurs \n",
" 2 3 2.c 0 1 1 Cal Grandeurs \n",
" 0 4 0 1 2 Cher 4opérations \n",
" 1 5 0 1 2 Cher 4opérations \n",
" 2 6 0 1 2 Rai 4opérations \n",
" 3 7 0 1 2 Cal 4opérations \n",
" 4 8 0 1 2 Com 4opérations \n",
" \n",
" comment \n",
" 0 Lecture du thermomètre \n",
" 1 Suivre programme de calculs \n",
" 2 Renverser un programme de calculs \n",
" 0 Lire le tableau et le graphique \n",
" 1 Décomposer le problème \n",
" 2 Manipuler les grandeurs \n",
" 3 Mener à bien les calculs \n",
" 4 Rédaction ,\n",
" 'students': id name surname mail commment tribe_id\n",
" 0 1 ABDALLAH ALLAOUI Taiassima None 1\n",
" 1 2 ADANI Ismou None 1\n",
" 2 3 AHAMADA Dhoulkamal None 1\n",
" 3 4 AHAMADI Asbahati None 1\n",
" 4 5 AHAMADI OUSSENI Ansufiddine None 1\n",
" 5 6 AHAMED Fayadhi None 1\n",
" 6 7 AHMED SAID Hadaïta None 1\n",
" 7 8 ALI MADI Anissa None 1\n",
" 8 9 ALI Raydel None 1\n",
" 9 10 ATTOUMANE ALI Fatima None 1\n",
" 10 11 BACHIROU Elzame None 1\n",
" 11 12 BINALI Zalida None 1\n",
" 12 13 BOINA Abdillah Mze Limassi None 1\n",
" 13 14 BOUDRA Zaankidine None 1\n",
" 14 15 BOURA Kayssoiria None 1\n",
" 15 16 HALADI Asna None 1\n",
" 16 17 HALIDI Soibrata None 1\n",
" 17 18 HAMEDALY Doulkifly None 1\n",
" 18 19 IBRAHIM Nassur None 1\n",
" 19 20 INOUSSA Anchoura None 1\n",
" 20 21 MOHAMED Nadia None 1\n",
" 21 22 MOUHOUDHOIRE Izak None 1\n",
" 22 23 MOUSSRI Bakari None 1\n",
" 23 24 SAÏD Fatoumia None 1\n",
" 24 25 SAKOTRA Claudiana None 1\n",
" 25 26 TOUFAIL Salahou None 1\n",
" 26 76 Ibrahim Chaharzade None 1,\n",
" 'tribe': id name grade\n",
" 0 1 302 3e}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datas = pull_datas(1, conn)\n",
"datas"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'DS1 mise en jambe'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datas['evaluation'][\"name\"][0]"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [],
"source": [
"q_df = datas[\"questions\"]\n",
"q_df = q_df.assign(\n",
" Nom = q_df[[\"name\", \"comment\"]].apply(lambda x: \" \".join(x), 1)\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
@ -63,220 +232,108 @@
" <th></th>\n",
" <th>id</th>\n",
" <th>name</th>\n",
" <th>term</th>\n",
" <th>t_id</th>\n",
" <th>score_rate</th>\n",
" <th>is_leveled</th>\n",
" <th>exercise_id</th>\n",
" <th>competence</th>\n",
" <th>domain</th>\n",
" <th>comment</th>\n",
" <th>Nom</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>DS1 mise en jambe</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cher</td>\n",
" <td>Grandeurs</td>\n",
" <td>Lecture du thermomètre</td>\n",
" <td>1 Lecture du thermomètre</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>DS1</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Cal</td>\n",
" <td>Grandeurs</td>\n",
" <td>Suivre programme de calculs</td>\n",
" <td>2 Suivre programme de calculs</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>DS1</td>\n",
" <td>2.c</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>Cal</td>\n",
" <td>Grandeurs</td>\n",
" <td>Renverser un programme de calculs</td>\n",
" <td>2.c Renverser un programme de calculs</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>0</th>\n",
" <td>4</td>\n",
" <td>DS2</td>\n",
" <td></td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>Cher</td>\n",
" <td>4opérations</td>\n",
" <td>Lire le tableau et le graphique</td>\n",
" <td>Lire le tableau et le graphique</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>1</th>\n",
" <td>5</td>\n",
" <td>DS2</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>6</td>\n",
" <td>DS2</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>7</td>\n",
" <td>DS3</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>8</td>\n",
" <td>Pyramide de pièces</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>9</td>\n",
" <td>DS3</td>\n",
" <td></td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>10</td>\n",
" <td>DS3</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>11</td>\n",
" <td>DS4</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>13</td>\n",
" <td>DS5</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>14</td>\n",
" <td>DM noel</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>15</td>\n",
" <td>DM noel</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>16</td>\n",
" <td>DS4</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>17</td>\n",
" <td>DS4</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>18</td>\n",
" <td>DS6</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>19</td>\n",
" <td>CM1</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>20</td>\n",
" <td>DNB blanc1</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>21</td>\n",
" <td>DNB blanc1</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>Cher</td>\n",
" <td>4opérations</td>\n",
" <td>Décomposer le problème</td>\n",
" <td>Décomposer le problème</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id name term t_id\n",
"0 1 DS1 mise en jambe 1 1\n",
"1 2 DS1 1 2\n",
"2 3 DS1 1 3\n",
"3 4 DS2 1 2\n",
"4 5 DS2 1 1\n",
"5 6 DS2 1 3\n",
"6 7 DS3 1 3\n",
"7 8 Pyramide de pièces 1 1\n",
"8 9 DS3 1 2\n",
"9 10 DS3 1 1\n",
"10 11 DS4 2 3\n",
"11 13 DS5 2 3\n",
"12 14 DM noel 2 1\n",
"13 15 DM noel 2 2\n",
"14 16 DS4 2 1\n",
"15 17 DS4 2 2\n",
"16 18 DS6 2 3\n",
"17 19 CM1 2 2\n",
"18 20 DNB blanc1 2 2\n",
"19 21 DNB blanc1 2 1"
" id name score_rate is_leveled exercise_id competence domain \\\n",
"0 1 1 0 1 1 Cher Grandeurs \n",
"1 2 2 0 1 1 Cal Grandeurs \n",
"2 3 2.c 0 1 1 Cal Grandeurs \n",
"0 4 0 1 2 Cher 4opérations \n",
"1 5 0 1 2 Cher 4opérations \n",
"\n",
" comment Nom \n",
"0 Lecture du thermomètre 1 Lecture du thermomètre \n",
"1 Suivre programme de calculs 2 Suivre programme de calculs \n",
"2 Renverser un programme de calculs 2.c Renverser un programme de calculs \n",
"0 Lire le tableau et le graphique Lire le tableau et le graphique \n",
"1 Décomposer le problème Décomposer le problème "
]
},
"execution_count": 9,
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"all_ev_description(conn)"
"q_df.head()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"ev = Evaluation.from_sqlite(21, conn)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'DNB blanc1'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ev.name"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 66,
"metadata": {},
"outputs": [
{
@ -310,58 +367,18 @@
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>64</td>\n",
" <td>1 - QCM</td>\n",
" <td>21</td>\n",
" <td>2018-02-07 00:00:00.000000</td>\n",
" <td>1</td>\n",
" <td>1 - Prendre la température</td>\n",
" <td>1</td>\n",
" <td>2017-09-05 00:00:00.000000</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>65</td>\n",
" <td>2 - Boite de chocolat</td>\n",
" <td>21</td>\n",
" <td>2018-02-07 00:00:00.000000</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>66</td>\n",
" <td>3 - Scratch</td>\n",
" <td>21</td>\n",
" <td>2018-02-07 00:00:00.000000</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>67</td>\n",
" <td>4 - Programme de calcul</td>\n",
" <td>21</td>\n",
" <td>2018-02-07 00:00:00.000000</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>68</td>\n",
" <td>5 - Macaron</td>\n",
" <td>21</td>\n",
" <td>2018-02-07 00:00:00.000000</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>69</td>\n",
" <td>6 - Inspecteur</td>\n",
" <td>21</td>\n",
" <td>2018-02-07 00:00:00.000000</td>\n",
" <td></td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>70</td>\n",
" <td>7 - La tache</td>\n",
" <td>21</td>\n",
" <td>2018-02-07 00:00:00.000000</td>\n",
" <td>2</td>\n",
" <td>2 - Maladroite!</td>\n",
" <td>1</td>\n",
" <td>2017-09-05 00:00:00.000000</td>\n",
" <td></td>\n",
" </tr>\n",
" </tbody>\n",
@ -370,22 +387,346 @@
],
"text/plain": [
" id name eval_id date comment\n",
"0 64 1 - QCM 21 2018-02-07 00:00:00.000000 \n",
"1 65 2 - Boite de chocolat 21 2018-02-07 00:00:00.000000 \n",
"2 66 3 - Scratch 21 2018-02-07 00:00:00.000000 \n",
"3 67 4 - Programme de calcul 21 2018-02-07 00:00:00.000000 \n",
"4 68 5 - Macaron 21 2018-02-07 00:00:00.000000 \n",
"5 69 6 - Inspecteur 21 2018-02-07 00:00:00.000000 \n",
"6 70 7 - La tache 21 2018-02-07 00:00:00.000000 "
"0 1 1 - Prendre la température 1 2017-09-05 00:00:00.000000 \n",
"1 2 2 - Maladroite! 1 2017-09-05 00:00:00.000000 "
]
},
"execution_count": 12,
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ev.ex_df"
"datas[\"exercises\"]"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>score_rate</th>\n",
" <th>competence</th>\n",
" <th>id</th>\n",
" <th>name</th>\n",
" <th>eval_id</th>\n",
" <th>date</th>\n",
" <th>comment</th>\n",
" <th>Nom</th>\n",
" <th>exercise_id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>Cher-Cal-Cal</td>\n",
" <td>1</td>\n",
" <td>1 - Prendre la température</td>\n",
" <td>1</td>\n",
" <td>2017-09-05 00:00:00.000000</td>\n",
" <td></td>\n",
" <td>Ex 1 - Prendre la température</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0</td>\n",
" <td>Cher-Cher-Rai-Cal-Com</td>\n",
" <td>2</td>\n",
" <td>2 - Maladroite!</td>\n",
" <td>1</td>\n",
" <td>2017-09-05 00:00:00.000000</td>\n",
" <td></td>\n",
" <td>Ex 2 - Maladroite!</td>\n",
" <td>2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" score_rate competence id name eval_id \\\n",
"0 0 Cher-Cal-Cal 1 1 - Prendre la température 1 \n",
"1 0 Cher-Cher-Rai-Cal-Com 2 2 - Maladroite! 1 \n",
"\n",
" date comment Nom \\\n",
"0 2017-09-05 00:00:00.000000 Ex 1 - Prendre la température \n",
"1 2017-09-05 00:00:00.000000 Ex 2 - Maladroite! \n",
"\n",
" exercise_id \n",
"0 1 \n",
"1 2 "
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ex_q = q_df.groupby(\"exercise_id\")\\\n",
" .agg({\"score_rate\": np.sum, \"competence\": lambda x: '-'.join(list(x))}) \\\n",
" .merge(datas[\"exercises\"], left_index=True, right_on='id')\n",
"ex_q = ex_q.assign(\n",
" Nom = ex_q[\"name\"].apply(lambda x: f\"Ex {x}\"),\n",
" exercise_id = ex_q[\"id\"]\n",
")\n",
"ex_q"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Nom</th>\n",
" <th>competence</th>\n",
" <th>score_rate</th>\n",
" <th>exercise_id</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Ex 1 - Prendre la température</td>\n",
" <td>Cher-Cal-Cal</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1 Lecture du thermomètre</td>\n",
" <td>Cher</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2 Suivre programme de calculs</td>\n",
" <td>Cal</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2.c Renverser un programme de calculs</td>\n",
" <td>Cal</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Ex 2 - Maladroite!</td>\n",
" <td>Cher-Cher-Rai-Cal-Com</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Lire le tableau et le graphique</td>\n",
" <td>Cher</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Décomposer le problème</td>\n",
" <td>Cher</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Manipuler les grandeurs</td>\n",
" <td>Rai</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Mener à bien les calculs</td>\n",
" <td>Cal</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Rédaction</td>\n",
" <td>Com</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Nom competence score_rate \\\n",
"0 Ex 1 - Prendre la température Cher-Cal-Cal 0 \n",
"0 1 Lecture du thermomètre Cher 0 \n",
"1 2 Suivre programme de calculs Cal 0 \n",
"2 2.c Renverser un programme de calculs Cal 0 \n",
"1 Ex 2 - Maladroite! Cher-Cher-Rai-Cal-Com 0 \n",
"0 Lire le tableau et le graphique Cher 0 \n",
"1 Décomposer le problème Cher 0 \n",
"2 Manipuler les grandeurs Rai 0 \n",
"3 Mener à bien les calculs Cal 0 \n",
"4 Rédaction Com 0 \n",
"\n",
" exercise_id \n",
"0 1 \n",
"0 1 \n",
"1 1 \n",
"2 1 \n",
"1 2 \n",
"0 2 \n",
"1 2 \n",
"2 2 \n",
"3 2 \n",
"4 2 "
]
},
"execution_count": 85,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sel_fields = ['Nom', 'competence', 'score_rate', 'exercise_id']\n",
"xls_df = pd.concat([ex_q[sel_fields], q_df[sel_fields]]).sort_values(\"exercise_id\")\n",
"xls_df"
]
},
{
"cell_type": "code",
"execution_count": 86,
"metadata": {},
"outputs": [],
"source": [
"writer = pd.ExcelWriter(\"./test.xlsx\", engine=\"xlsxwriter\")\n",
"xls_df.to_excel(writer, index=False, sheet_name='DNB blanc 2')"
]
},
{
"cell_type": "code",
"execution_count": 87,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"workbook = writer.book\n",
"worksheet = writer.sheets['DNB blanc 2']"
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"first_line_format = workbook.add_format({\"align\": 'center', \"rotation\":90})\n",
"\n",
"worksheet.set_column('A:D', 20)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 89,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"writer.save()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Fait au DNB blanc 1"
]
},
{