2017-2018/Notes/DB vers xlsx.ipynb

2526 lines
78 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 1,
2018-02-09 03:02:48 +00:00
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import xlsxwriter"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from repytex.worksheets.worksheet import pull_datas\n",
2018-04-23 06:50:06 +00:00
"from repytex.reports.eval import pull_datas as pull_sqlite\n",
"import pandas as pd\n",
"import numpy as np\n",
"import sqlite3"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"conn = sqlite3.connect('./recopytex.db')"
]
},
2018-04-23 06:50:06 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# to xlxs"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 4,
"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}"
]
},
2018-04-23 06:50:06 +00:00
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datas = pull_datas(1, conn)\n",
"datas"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'DS1 mise en jambe'"
]
},
2018-04-23 06:50:06 +00:00
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datas['evaluation'][\"name\"][0]"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 6,
"metadata": {
"collapsed": true
},
"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",
2018-04-23 06:50:06 +00:00
"execution_count": 7,
2018-02-09 03:02:48 +00:00
"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>id</th>\n",
" <th>name</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",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
2018-02-09 03:02:48 +00:00
" <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",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
2018-02-09 03:02:48 +00:00
" <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",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
2018-02-09 03:02:48 +00:00
" <td>3</td>\n",
" <td>2.c</td>\n",
" <td>0</td>\n",
2018-02-09 03:02:48 +00:00
" <td>1</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",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4</td>\n",
" <td></td>\n",
" <td>0</td>\n",
2018-02-09 03:02:48 +00:00
" <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",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>5</td>\n",
" <td></td>\n",
" <td>0</td>\n",
2018-02-09 03:02:48 +00:00
" <td>1</td>\n",
" <td>2</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",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 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 "
]
},
2018-04-23 06:50:06 +00:00
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"q_df.head()"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 8,
"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>id</th>\n",
" <th>name</th>\n",
" <th>eval_id</th>\n",
" <th>date</th>\n",
" <th>comment</th>\n",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" </thead>\n",
" <tbody>\n",
2018-02-09 03:02:48 +00:00
" <tr>\n",
" <th>0</th>\n",
2018-02-09 03:02:48 +00:00
" <td>1</td>\n",
" <td>1 - Prendre la température</td>\n",
2018-02-09 03:02:48 +00:00
" <td>1</td>\n",
" <td>2017-09-05 00:00:00.000000</td>\n",
" <td></td>\n",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
2018-02-09 03:02:48 +00:00
" <td>2</td>\n",
" <td>2 - Maladroite!</td>\n",
2018-02-09 03:02:48 +00:00
" <td>1</td>\n",
" <td>2017-09-05 00:00:00.000000</td>\n",
" <td></td>\n",
2018-02-09 03:02:48 +00:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 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 "
2018-02-09 03:02:48 +00:00
]
},
2018-04-23 06:50:06 +00:00
"execution_count": 8,
2018-02-09 03:02:48 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datas[\"exercises\"]"
2018-02-09 03:02:48 +00:00
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"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": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"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": 11,
"metadata": {
"collapsed": true
},
"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": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#workbook = writer.book\n",
"#worksheet = writer.sheets['DNB blanc 2']"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"outputs": [],
"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": 14,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#writer.save()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## From xlsx"
]
},
{
"cell_type": "code",
"execution_count": 15,
"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>competence</th>\n",
2018-04-23 06:50:06 +00:00
" <th>Barème</th>\n",
" <th>A. Rachma</th>\n",
" <th>A. kassim</th>\n",
" <th>A. Irchadi</th>\n",
" <th>A. Mikidadi</th>\n",
" <th>A. Zaidou</th>\n",
" <th>B. Rakchat</th>\n",
" <th>B. Chadia</th>\n",
" <th>C. Faycoil</th>\n",
" <th>...</th>\n",
" <th>S. Nadjoi</th>\n",
" <th>S. Rachida</th>\n",
" <th>S. Hairidine</th>\n",
" <th>T. Zoubert</th>\n",
" <th>Moyenne</th>\n",
" <th>Min</th>\n",
" <th>Q1</th>\n",
" <th>me</th>\n",
" <th>Q3</th>\n",
" <th>max</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>DNB blanc 2</th>\n",
" <td>NaN</td>\n",
" <td>116</td>\n",
" <td>51</td>\n",
" <td>10</td>\n",
" <td>63</td>\n",
" <td>53</td>\n",
" <td>27</td>\n",
" <td>17</td>\n",
" <td>32</td>\n",
" <td>26</td>\n",
" <td>...</td>\n",
" <td>49</td>\n",
" <td>28</td>\n",
" <td>12</td>\n",
" <td>10</td>\n",
" <td>35.952381</td>\n",
" <td>10.0</td>\n",
" <td>25.0</td>\n",
" <td>32.0</td>\n",
" <td>51.0</td>\n",
" <td>70.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Ex 1 - Le fameux triangle</th>\n",
" <td>NaN</td>\n",
" <td>10</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>10</td>\n",
" <td>9</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>7</td>\n",
" <td>6</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>3.857143</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3.0</td>\n",
" <td>7.0</td>\n",
" <td>10.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1 Reconnaitre Pythagore</th>\n",
" <td>Mod</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
2018-04-23 06:50:06 +00:00
" <td>0</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1.571429</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2.0</td>\n",
" <td>3.0</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>1 Calculs</th>\n",
" <td>Cal</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
2018-04-23 06:50:06 +00:00
" <td>0</td>\n",
" <td>2</td>\n",
2018-04-23 06:50:06 +00:00
" <td>0</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1.428571</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2.0</td>\n",
" <td>3.0</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2 Calcul de l'aire</th>\n",
" <td>Rep</td>\n",
" <td>4</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0.857143</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>4.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
2018-04-23 06:50:06 +00:00
"<p>5 rows × 29 columns</p>\n",
"</div>"
],
"text/plain": [
2018-04-23 06:50:06 +00:00
" competence Barème A. Rachma A. kassim \\\n",
"DNB blanc 2 NaN 116 51 10 \n",
"Ex 1 - Le fameux triangle NaN 10 5 0 \n",
"1 Reconnaitre Pythagore Mod 3 3 0 \n",
"1 Calculs Cal 3 2 0 \n",
"2 Calcul de l'aire Rep 4 0 0 \n",
"\n",
2018-04-23 06:50:06 +00:00
" A. Irchadi A. Mikidadi A. Zaidou B. Rakchat \\\n",
"DNB blanc 2 63 53 27 17 \n",
"Ex 1 - Le fameux triangle 10 9 3 0 \n",
"1 Reconnaitre Pythagore 3 3 1 0 \n",
"1 Calculs 3 3 2 0 \n",
"2 Calcul de l'aire 4 3 0 0 \n",
"\n",
2018-04-23 06:50:06 +00:00
" B. Chadia C. Faycoil ... S. Nadjoi S. Rachida \\\n",
"DNB blanc 2 32 26 ... 49 28 \n",
"Ex 1 - Le fameux triangle 5 0 ... 7 6 \n",
"1 Reconnaitre Pythagore 3 0 ... 3 3 \n",
"1 Calculs 2 0 ... 3 3 \n",
"2 Calcul de l'aire 0 0 ... 1 0 \n",
"\n",
" S. Hairidine T. Zoubert Moyenne Min Q1 \\\n",
"DNB blanc 2 12 10 35.952381 10.0 25.0 \n",
"Ex 1 - Le fameux triangle 0 0 3.857143 0.0 0.0 \n",
"1 Reconnaitre Pythagore 0 0 1.571429 0.0 0.0 \n",
"1 Calculs 0 0 1.428571 0.0 0.0 \n",
"2 Calcul de l'aire 0 0 0.857143 0.0 0.0 \n",
"\n",
" me Q3 max \n",
"DNB blanc 2 32.0 51.0 70.0 \n",
"Ex 1 - Le fameux triangle 3.0 7.0 10.0 \n",
"1 Reconnaitre Pythagore 2.0 3.0 3.0 \n",
"1 Calculs 2.0 3.0 3.0 \n",
"2 Calcul de l'aire 0.0 1.0 4.0 \n",
"\n",
"[5 rows x 29 columns]"
]
},
2018-04-23 06:50:06 +00:00
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2018-04-23 06:50:06 +00:00
"df = pd.read_excel(\"./DNB_blanc2/DNB2_306.xlsx\")\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"On enlève les colonnes inutiles et on format les prénoms"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import unicodedata\n",
"def normalize_str(s):\n",
" return unicodedata.normalize('NFD', s).encode('ascii', 'ignore').lower()"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 17,
"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",
2018-04-23 06:50:06 +00:00
" <th>b'rachma'</th>\n",
" <th>b'kassim'</th>\n",
" <th>b'irchadi'</th>\n",
" <th>b'mikidadi'</th>\n",
" <th>b'zaidou'</th>\n",
" <th>b'rakchat'</th>\n",
" <th>b'chadia'</th>\n",
" <th>b'faycoil'</th>\n",
" <th>b'djael'</th>\n",
" <th>b'doulka-rynaini'</th>\n",
" <th>...</th>\n",
" <th>b'chamsidine'</th>\n",
" <th>b'dania'</th>\n",
" <th>b'issoufi'</th>\n",
" <th>b'el-fahar'</th>\n",
" <th>b'fayadhui'</th>\n",
" <th>b'dalila'</th>\n",
" <th>b'nadjoi'</th>\n",
" <th>b'rachida'</th>\n",
" <th>b'hairidine'</th>\n",
" <th>b'zoubert'</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>DNB blanc 2</th>\n",
" <td>51</td>\n",
" <td>10</td>\n",
" <td>63</td>\n",
" <td>53</td>\n",
" <td>27</td>\n",
" <td>17</td>\n",
" <td>32</td>\n",
" <td>26</td>\n",
" <td>39</td>\n",
" <td>27</td>\n",
" <td>...</td>\n",
" <td>33</td>\n",
" <td>67</td>\n",
" <td>70</td>\n",
" <td>59</td>\n",
" <td>10</td>\n",
" <td>47</td>\n",
" <td>49</td>\n",
" <td>28</td>\n",
" <td>12</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>Ex 1 - Le fameux triangle</th>\n",
" <td>5</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>10</td>\n",
" <td>9</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>5</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
2018-04-23 06:50:06 +00:00
" <td>0</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>9</td>\n",
" <td>8</td>\n",
" <td>8</td>\n",
" <td>0</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>6</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>1 Reconnaitre Pythagore</th>\n",
" <td>3</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>3</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>3</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>2</td>\n",
2018-04-23 06:50:06 +00:00
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>1 Calculs</th>\n",
" <td>2</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
2018-04-23 06:50:06 +00:00
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2 Calcul de l'aire</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 21 columns</p>\n",
"</div>"
],
"text/plain": [
" b'rachma' b'kassim' b'irchadi' b'mikidadi' \\\n",
"DNB blanc 2 51 10 63 53 \n",
"Ex 1 - Le fameux triangle 5 0 10 9 \n",
"1 Reconnaitre Pythagore 3 0 3 3 \n",
"1 Calculs 2 0 3 3 \n",
"2 Calcul de l'aire 0 0 4 3 \n",
"\n",
" b'zaidou' b'rakchat' b'chadia' b'faycoil' \\\n",
"DNB blanc 2 27 17 32 26 \n",
"Ex 1 - Le fameux triangle 3 0 5 0 \n",
"1 Reconnaitre Pythagore 1 0 3 0 \n",
"1 Calculs 2 0 2 0 \n",
"2 Calcul de l'aire 0 0 0 0 \n",
"\n",
" b'djael' b'doulka-rynaini' ... \\\n",
"DNB blanc 2 39 27 ... \n",
"Ex 1 - Le fameux triangle 1 0 ... \n",
"1 Reconnaitre Pythagore 0 0 ... \n",
"1 Calculs 0 0 ... \n",
"2 Calcul de l'aire 1 0 ... \n",
"\n",
" b'chamsidine' b'dania' b'issoufi' b'el-fahar' \\\n",
"DNB blanc 2 33 67 70 59 \n",
"Ex 1 - Le fameux triangle 3 9 8 8 \n",
"1 Reconnaitre Pythagore 2 3 3 3 \n",
"1 Calculs 1 2 3 3 \n",
"2 Calcul de l'aire 0 4 2 2 \n",
"\n",
" b'fayadhui' b'dalila' b'nadjoi' b'rachida' \\\n",
"DNB blanc 2 10 47 49 28 \n",
"Ex 1 - Le fameux triangle 0 7 7 6 \n",
"1 Reconnaitre Pythagore 0 3 3 3 \n",
"1 Calculs 0 3 3 3 \n",
"2 Calcul de l'aire 0 1 1 0 \n",
"\n",
" b'hairidine' b'zoubert' \n",
"DNB blanc 2 12 10 \n",
"Ex 1 - Le fameux triangle 0 0 \n",
"1 Reconnaitre Pythagore 0 0 \n",
"1 Calculs 0 0 \n",
"2 Calcul de l'aire 0 0 \n",
"\n",
"[5 rows x 21 columns]"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df.drop(['competence', 'Barème','Moyenne',\n",
" 'Min', 'Q1', 'me', 'Q3', 'max'], 1)\n",
"df.columns = [normalize_str(i.split(\". \")[-1]) for i in df.columns]\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"On enlèves les lignes calculées par excel pour ne garder que les données"
]
},
{
"cell_type": "code",
"execution_count": 18,
"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>b'rachma'</th>\n",
" <th>b'kassim'</th>\n",
" <th>b'irchadi'</th>\n",
" <th>b'mikidadi'</th>\n",
" <th>b'zaidou'</th>\n",
" <th>b'rakchat'</th>\n",
" <th>b'chadia'</th>\n",
" <th>b'faycoil'</th>\n",
" <th>b'djael'</th>\n",
" <th>b'doulka-rynaini'</th>\n",
" <th>...</th>\n",
" <th>b'chamsidine'</th>\n",
" <th>b'dania'</th>\n",
" <th>b'issoufi'</th>\n",
" <th>b'el-fahar'</th>\n",
" <th>b'fayadhui'</th>\n",
" <th>b'dalila'</th>\n",
" <th>b'nadjoi'</th>\n",
" <th>b'rachida'</th>\n",
" <th>b'hairidine'</th>\n",
" <th>b'zoubert'</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1 Reconnaitre Pythagore</th>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1 Calculs</th>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2 Calcul de l'aire</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3 Commentaire de Tristan</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1.a Lecture de tableau</th>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 21 columns</p>\n",
"</div>"
],
"text/plain": [
" b'rachma' b'kassim' b'irchadi' b'mikidadi' \\\n",
"1 Reconnaitre Pythagore 3 0 3 3 \n",
"1 Calculs 2 0 3 3 \n",
"2 Calcul de l'aire 0 0 4 3 \n",
"3 Commentaire de Tristan 1 0 2 2 \n",
"1.a Lecture de tableau 3 0 3 3 \n",
"\n",
" b'zaidou' b'rakchat' b'chadia' b'faycoil' \\\n",
"1 Reconnaitre Pythagore 1 0 3 0 \n",
"1 Calculs 2 0 2 0 \n",
"2 Calcul de l'aire 0 0 0 0 \n",
"3 Commentaire de Tristan 0 0 0 0 \n",
"1.a Lecture de tableau 3 3 3 3 \n",
"\n",
" b'djael' b'doulka-rynaini' ... \\\n",
"1 Reconnaitre Pythagore 0 0 ... \n",
"1 Calculs 0 0 ... \n",
"2 Calcul de l'aire 1 0 ... \n",
"3 Commentaire de Tristan 3 0 ... \n",
"1.a Lecture de tableau 3 0 ... \n",
"\n",
" b'chamsidine' b'dania' b'issoufi' b'el-fahar' \\\n",
"1 Reconnaitre Pythagore 2 3 3 3 \n",
"1 Calculs 1 2 3 3 \n",
"2 Calcul de l'aire 0 4 2 2 \n",
"3 Commentaire de Tristan 1 2 1 0 \n",
"1.a Lecture de tableau 3 3 3 3 \n",
"\n",
" b'fayadhui' b'dalila' b'nadjoi' b'rachida' \\\n",
"1 Reconnaitre Pythagore 0 3 3 3 \n",
"1 Calculs 0 3 3 3 \n",
"2 Calcul de l'aire 0 1 1 0 \n",
"3 Commentaire de Tristan 0 1 0 0 \n",
"1.a Lecture de tableau 0 3 3 3 \n",
"\n",
" b'hairidine' b'zoubert' \n",
"1 Reconnaitre Pythagore 0 0 \n",
"1 Calculs 0 0 \n",
"2 Calcul de l'aire 0 0 \n",
"3 Commentaire de Tristan 0 0 \n",
"1.a Lecture de tableau 0 0 \n",
"\n",
"[5 rows x 21 columns]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df[list(~df.reset_index()[\"index\"].apply(lambda x: x.startswith(\"Ex\") or x.startswith(\"DNB\")))]\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"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>index</th>\n",
" <th>b'rachma'</th>\n",
" <th>b'kassim'</th>\n",
" <th>b'irchadi'</th>\n",
" <th>b'mikidadi'</th>\n",
" <th>b'zaidou'</th>\n",
" <th>b'rakchat'</th>\n",
" <th>b'chadia'</th>\n",
" <th>b'faycoil'</th>\n",
" <th>b'djael'</th>\n",
" <th>...</th>\n",
" <th>b'chamsidine'</th>\n",
" <th>b'dania'</th>\n",
" <th>b'issoufi'</th>\n",
" <th>b'el-fahar'</th>\n",
" <th>b'fayadhui'</th>\n",
" <th>b'dalila'</th>\n",
" <th>b'nadjoi'</th>\n",
" <th>b'rachida'</th>\n",
" <th>b'hairidine'</th>\n",
" <th>b'zoubert'</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1 Reconnaitre Pythagore</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1 Calculs</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2 Calcul de l'aire</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3 Commentaire de Tristan</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1.a Lecture de tableau</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 22 columns</p>\n",
"</div>"
],
"text/plain": [
" index b'rachma' b'kassim' b'irchadi' b'mikidadi' \\\n",
"0 1 Reconnaitre Pythagore 3 0 3 3 \n",
"1 1 Calculs 2 0 3 3 \n",
"2 2 Calcul de l'aire 0 0 4 3 \n",
"3 3 Commentaire de Tristan 1 0 2 2 \n",
"4 1.a Lecture de tableau 3 0 3 3 \n",
"\n",
" b'zaidou' b'rakchat' b'chadia' b'faycoil' b'djael' ... \\\n",
"0 1 0 3 0 0 ... \n",
"1 2 0 2 0 0 ... \n",
"2 0 0 0 0 1 ... \n",
"3 0 0 0 0 3 ... \n",
"4 3 3 3 3 3 ... \n",
"\n",
" b'chamsidine' b'dania' b'issoufi' b'el-fahar' b'fayadhui' b'dalila' \\\n",
"0 2 3 3 3 0 3 \n",
"1 1 2 3 3 0 3 \n",
"2 0 4 2 2 0 1 \n",
"3 1 2 1 0 0 1 \n",
"4 3 3 3 3 0 3 \n",
"\n",
" b'nadjoi' b'rachida' b'hairidine' b'zoubert' \n",
"0 3 3 0 0 \n",
"1 3 3 0 0 \n",
"2 1 0 0 0 \n",
"3 0 0 0 0 \n",
"4 3 3 0 0 \n",
"\n",
"[5 rows x 22 columns]"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df.reset_index()\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"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>index</th>\n",
" <th>b'rachma'</th>\n",
" <th>b'kassim'</th>\n",
" <th>b'irchadi'</th>\n",
" <th>b'mikidadi'</th>\n",
" <th>b'zaidou'</th>\n",
" <th>b'rakchat'</th>\n",
" <th>b'chadia'</th>\n",
" <th>b'faycoil'</th>\n",
" <th>b'djael'</th>\n",
" <th>...</th>\n",
" <th>b'issoufi'</th>\n",
" <th>b'el-fahar'</th>\n",
" <th>b'fayadhui'</th>\n",
" <th>b'dalila'</th>\n",
" <th>b'nadjoi'</th>\n",
" <th>b'rachida'</th>\n",
" <th>b'hairidine'</th>\n",
" <th>b'zoubert'</th>\n",
" <th>q_comment</th>\n",
" <th>q_name</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1 Reconnaitre Pythagore</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>Reconnaitre Pythagore</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1 Calculs</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>Calculs</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2 Calcul de l'aire</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>4</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>Calcul de l'aire</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3 Commentaire de Tristan</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>...</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>Commentaire de Tristan</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1.a Lecture de tableau</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>...</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>Lecture de tableau</td>\n",
" <td>1.a</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 24 columns</p>\n",
"</div>"
],
"text/plain": [
" index b'rachma' b'kassim' b'irchadi' b'mikidadi' \\\n",
"0 1 Reconnaitre Pythagore 3 0 3 3 \n",
"1 1 Calculs 2 0 3 3 \n",
"2 2 Calcul de l'aire 0 0 4 3 \n",
"3 3 Commentaire de Tristan 1 0 2 2 \n",
"4 1.a Lecture de tableau 3 0 3 3 \n",
"\n",
" b'zaidou' b'rakchat' b'chadia' b'faycoil' b'djael' ... b'issoufi' \\\n",
"0 1 0 3 0 0 ... 3 \n",
"1 2 0 2 0 0 ... 3 \n",
"2 0 0 0 0 1 ... 2 \n",
"3 0 0 0 0 3 ... 1 \n",
"4 3 3 3 3 3 ... 3 \n",
"\n",
" b'el-fahar' b'fayadhui' b'dalila' b'nadjoi' b'rachida' b'hairidine' \\\n",
"0 3 0 3 3 3 0 \n",
"1 3 0 3 3 3 0 \n",
"2 2 0 1 1 0 0 \n",
"3 0 0 1 0 0 0 \n",
"4 3 0 3 3 3 0 \n",
"\n",
" b'zoubert' q_comment q_name \n",
"0 0 Reconnaitre Pythagore 1 \n",
"1 0 Calculs 1 \n",
"2 0 Calcul de l'aire 2 \n",
"3 0 Commentaire de Tristan 3 \n",
"4 0 Lecture de tableau 1.a \n",
"\n",
"[5 rows x 24 columns]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df.assign(\n",
" q_name = df[\"index\"].apply(lambda x: x.split(\" \")[0]),\n",
" q_comment = df[\"index\"].apply(lambda x: \" \".join(x.split(\" \")[1:])),\n",
" )\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 21,
"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>index</th>\n",
" <th>q_name</th>\n",
" <th>q_comment</th>\n",
" <th>level_3</th>\n",
" <th>0</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1 Reconnaitre Pythagore</td>\n",
" <td>1</td>\n",
" <td>Reconnaitre Pythagore</td>\n",
" <td>b'rachma'</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1 Reconnaitre Pythagore</td>\n",
" <td>1</td>\n",
" <td>Reconnaitre Pythagore</td>\n",
" <td>b'kassim'</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1 Reconnaitre Pythagore</td>\n",
" <td>1</td>\n",
" <td>Reconnaitre Pythagore</td>\n",
" <td>b'irchadi'</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1 Reconnaitre Pythagore</td>\n",
" <td>1</td>\n",
" <td>Reconnaitre Pythagore</td>\n",
" <td>b'mikidadi'</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1 Reconnaitre Pythagore</td>\n",
" <td>1</td>\n",
" <td>Reconnaitre Pythagore</td>\n",
" <td>b'zaidou'</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" index q_name q_comment level_3 0\n",
"0 1 Reconnaitre Pythagore 1 Reconnaitre Pythagore b'rachma' 3\n",
"1 1 Reconnaitre Pythagore 1 Reconnaitre Pythagore b'kassim' 0\n",
"2 1 Reconnaitre Pythagore 1 Reconnaitre Pythagore b'irchadi' 3\n",
"3 1 Reconnaitre Pythagore 1 Reconnaitre Pythagore b'mikidadi' 3\n",
"4 1 Reconnaitre Pythagore 1 Reconnaitre Pythagore b'zaidou' 1"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = df.set_index([\"index\", \"q_name\", \"q_comment\"]).stack().reset_index()\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"df = df.rename(columns={0:\"value\", \"level_3\": \"norm_surname\"})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Il ne reste plus qu'à trouver les correspondances avec la base de données."
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"sqlite_datas = pull_sqlite(33, conn)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Les élèves"
]
},
{
"cell_type": "code",
"execution_count": 24,
"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>id</th>\n",
" <th>name</th>\n",
" <th>surname</th>\n",
" <th>mail</th>\n",
" <th>commment</th>\n",
" <th>tribe_id</th>\n",
" <th>norm_surname</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>27</td>\n",
" <td>ABDALLAH</td>\n",
" <td>Rachma</td>\n",
" <td></td>\n",
" <td>None</td>\n",
" <td>2</td>\n",
" <td>b'rachma'</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>28</td>\n",
" <td>ABDOU</td>\n",
" <td>Kassim</td>\n",
" <td></td>\n",
" <td>None</td>\n",
" <td>2</td>\n",
" <td>b'kassim'</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>29</td>\n",
" <td>AHAMADI</td>\n",
" <td>Irchadi</td>\n",
" <td></td>\n",
" <td>None</td>\n",
" <td>2</td>\n",
" <td>b'irchadi'</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>30</td>\n",
" <td>AHAMED</td>\n",
" <td>Mikidadi</td>\n",
" <td></td>\n",
" <td>None</td>\n",
" <td>2</td>\n",
" <td>b'mikidadi'</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>31</td>\n",
" <td>ANLI</td>\n",
" <td>El Anziz</td>\n",
" <td></td>\n",
" <td>None</td>\n",
" <td>2</td>\n",
" <td>b'el anziz'</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" id name surname mail commment tribe_id norm_surname\n",
"0 27 ABDALLAH Rachma None 2 b'rachma'\n",
"1 28 ABDOU Kassim None 2 b'kassim'\n",
"2 29 AHAMADI Irchadi None 2 b'irchadi'\n",
"3 30 AHAMED Mikidadi None 2 b'mikidadi'\n",
"4 31 ANLI El Anziz None 2 b'el anziz'"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"st_df = sqlite_datas[\"students\"]\n",
"st_df = st_df.assign(\n",
" norm_surname = st_df[\"surname\"].apply(normalize_str)\n",
")\n",
"st_df.head()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"df = pd.merge(df, st_df, left_on='norm_surname', right_on=\"norm_surname\")[[\"q_comment\", \"id\", \"value\"]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Les questions"
]
},
{
"cell_type": "code",
"execution_count": 26,
"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>id</th>\n",
" <th>name</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",
" </tr>\n",
2018-04-23 06:50:06 +00:00
" </thead>\n",
" <tbody>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>0</th>\n",
" <td>369</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>114</td>\n",
" <td>Mod</td>\n",
" <td>Geometrie</td>\n",
" <td>Reconnaitre Pythagore</td>\n",
" </tr>\n",
" <tr>\n",
2018-04-23 06:50:06 +00:00
" <th>1</th>\n",
" <td>370</td>\n",
" <td>1</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
2018-04-23 06:50:06 +00:00
" <td>114</td>\n",
" <td>Cal</td>\n",
" <td>Geometrie</td>\n",
" <td>Calculs</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>371</td>\n",
" <td>2</td>\n",
2018-04-23 06:50:06 +00:00
" <td>4</td>\n",
" <td>0</td>\n",
" <td>114</td>\n",
" <td>Rep</td>\n",
" <td>Geometrie</td>\n",
" <td>Calcul de l'aire</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>372</td>\n",
" <td>1.a</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>115</td>\n",
" <td>Cher</td>\n",
" <td>Statistiques</td>\n",
" <td>Lecture de tableau</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>373</td>\n",
" <td>1.b et 2.b</td>\n",
" <td>3</td>\n",
" <td>0</td>\n",
" <td>115</td>\n",
" <td>Rep</td>\n",
" <td>Statistiques</td>\n",
" <td>Minimum et maximum</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2018-04-23 06:50:06 +00:00
" id name score_rate is_leveled exercise_id competence \\\n",
"0 369 1 3 0 114 Mod \n",
"1 370 1 3 0 114 Cal \n",
"2 371 2 4 0 114 Rep \n",
"0 372 1.a 3 0 115 Cher \n",
"1 373 1.b et 2.b 3 0 115 Rep \n",
"\n",
2018-04-23 06:50:06 +00:00
" domain comment \n",
"0 Geometrie Reconnaitre Pythagore \n",
"1 Geometrie Calculs \n",
"2 Geometrie Calcul de l'aire \n",
"0 Statistiques Lecture de tableau \n",
"1 Statistiques Minimum et maximum "
]
},
2018-04-23 06:50:06 +00:00
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2018-04-23 06:50:06 +00:00
"q_df = sqlite_datas[\"questions\"]\n",
"q_df.head()"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
2018-04-23 06:50:06 +00:00
"df = pd.merge(df, q_df, left_on=\"q_comment\", right_on=\"comment\")[[\"id_x\", \"id_y\", \"value\"]]\\\n",
" .rename(columns={\"id_x\": \"student_id\", \"id_y\": \"question_id\"})"
]
},
{
2018-04-23 06:50:06 +00:00
"cell_type": "markdown",
"metadata": {},
"source": [
2018-04-23 06:50:06 +00:00
"Yes ça y est je dois les avoir!"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
2018-04-23 06:50:06 +00:00
"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>student_id</th>\n",
" <th>question_id</th>\n",
" <th>value</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>27</td>\n",
" <td>369</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>28</td>\n",
" <td>369</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>29</td>\n",
" <td>369</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>30</td>\n",
" <td>369</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>32</td>\n",
" <td>369</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2018-04-23 06:50:06 +00:00
" student_id question_id value\n",
"0 27 369 3\n",
"1 28 369 0\n",
"2 29 369 3\n",
"3 30 369 3\n",
"4 32 369 1"
]
},
2018-04-23 06:50:06 +00:00
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2018-04-23 06:50:06 +00:00
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Et maintenant on sauvegarde tout!"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 29,
"metadata": {
"collapsed": true
},
"outputs": [],
2018-04-23 06:50:06 +00:00
"source": [
"df.to_sql(\"score\", conn, if_exists='append', index=False)"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": 30,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'fdsqfdsq' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-30-a7adbbdd0ac1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfdsqfdsq\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'fdsqfdsq' is not defined"
]
}
],
"source": [
"fdsqfdsq"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
2018-04-23 06:50:06 +00:00
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Fait au DNB blanc 1"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
2018-02-09 03:02:48 +00:00
"wb = xlsxwriter.Workbook(\"DNB_BLANC_pro1.xlsx\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Formatages"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
2018-02-09 03:02:48 +00:00
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"eval_format = wb.add_format({'bold': True, 'font_color': 'red'})\n",
"eval_cell = wb.add_format()\n",
"eval_cell.set_bg_color(\"red\")\n",
"# exo_cell"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"La feuille de calcul"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"wb = xlsxwriter.Workbook(\"DS4_302.xlsx\")"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ws = wb.add_worksheet()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"En tête du tableau"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ws.write(0,1,\"Competence\")\n",
"ws.write(0,2,\"Barème\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Toutes les questions et exercices"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def q_line(q, row, ws):\n",
" ws.write(row, 0, f\"{q.name} - {q.comment}\")\n",
" ws.write(row, 1, f\"{q.competence}\")\n",
" ws.write(row, 2, q.score_rate)"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def exo_block(exo, row, ws):\n",
" qrow = row\n",
" for q in exo[\"questions\"]:\n",
" qrow += 1\n",
" q_line(q, qrow, ws)\n",
" ws.write(row, 0, f\"Ex {exo['name']}\")\n",
" row_range = \", \".join([f\"C{i}\" for i in range(row+2, qrow+2)])\n",
" for i in range(30):\n",
" ws.write(row, i+2, f\"=SUM({row_range})\")\n",
" return qrow"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
2018-02-09 03:02:48 +00:00
"collapsed": true,
"scrolled": false
},
"outputs": [],
"source": [
"row = 2\n",
"exo_rows = []\n",
"for exo in ev.exercises:\n",
" exo_rows.append(row)\n",
" row = exo_block(exo, row, ws) + 1\n",
"ws.write(1,0, ev.name, eval_format)\n",
"exo_xls_range = \", \".join([f\"C{i+1}\" for i in exo_rows])\n",
"for i in range(30):\n",
" ws.write(1,i+2, f\"=SUM({exo_xls_range})\", eval_format)"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"wb.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Avec openpyxl"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
2018-02-09 03:02:48 +00:00
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from openpyxl import Workbook\n",
"from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font, colors"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"colors.RED"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"wb = Workbook()"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ws = wb.create_sheet(ev.name)"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"ws.cell(1,2,\"Competence\")\n",
"ws.cell(1,3,\"Barème\")"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
2018-02-09 03:02:48 +00:00
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def q_line(q, row, ws):\n",
" ws.cell(row, 1, f\"{q.name} - {q.comment}\")\n",
" ws.cell(row, 2, f\"{q.competence}\")\n",
" ws.cell(row, 3, q.score_rate)"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def exo_block(exo, row, ws):\n",
" qrow = row\n",
" for q in exo[\"questions\"]:\n",
" qrow += 1\n",
" q_line(q, qrow, ws)\n",
" ws.cell(row, 1, f\"Ex {exo['name']}\")\n",
" row_range = \", \".join([f\"C{i}\" for i in range(row+1, qrow+1)])\n",
" ws.cell(row, 3, f\"=SUM({row_range})\")\n",
" return qrow"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"row = 3\n",
"exo_rows = []\n",
"for exo in ev.exercises:\n",
" exo_rows.append(row)\n",
" row = exo_block(exo, row, ws) + 1\n",
"eval_row = ws.row_dimensions[2]\n",
"eval_row.fill = PatternFill(bgColor=colors.RED)\n",
"ws.cell(2,1, ev.name)\n",
"exo_xls_range = \", \".join([f\"C{i}\" for i in exo_rows])\n",
"ws.cell(2,3, f\"=SUM({exo_xls_range})\")"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
2018-02-09 03:02:48 +00:00
"source": [
"ev.tribe"
]
},
{
"cell_type": "code",
2018-04-23 06:50:06 +00:00
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
2018-02-09 03:02:48 +00:00
"wb.save(f\"./{ev.name}-{ev.tribe}.xlsx\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2018-04-23 06:50:06 +00:00
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}