{ "cells": [ { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pandas as pd\n", "from texenv import texenv\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Informations sur le devoir" ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{'classe': '\\\\premiereS', 'date': '4 mai 2015', 'titre': 'DM 7'}" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ds_name = \"DM_0504\"\n", "classe = \"1S\"\n", "\n", "latex_info = {}\n", "latex_info['titre'] = 'DM 7'\n", "latex_info['classe'] = \"\\\\premiereS\"\n", "latex_info['date'] = '4 mai 2015'\n", "latex_info" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Import et premiers traitements" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [], "source": [ "notes = pd.ExcelFile(\"./../../../notes_\"+classe+\".xls\")\n", "notes.sheet_names\n", "notes = notes.parse(ds_name)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "Index(['DM_0504', 'a_arrondi', 'Malus', 'Exercice 1', '1.1.a (domaines)',\n", " '1.1.b (Dérivée)', '1.1.c (Variations)', '1.2.a (domaines)',\n", " '1.2.b (Dérivée)', '1.2.c (Variations)', '1.3.a (Courbe)',\n", " '1.3.b (Intersection)', '1.3.c (Resolution graphique)', '1 Malus',\n", " 'Exercice 2', '2.1 (variations)', '2.2.a (Equation tangente)',\n", " '2.2.b (Position tangente)', '2.2.c (Courbe)', 'Exercice 3',\n", " '3.1 (domaines)', '3.2 (variations)'],\n", " dtype='object')" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "notes.index" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": true }, "outputs": [], "source": [ "notes = notes.T" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [], "source": [ "notes = notes.drop('a_arrondi', axis=1)" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "collapsed": false }, "outputs": [], "source": [ "barem = notes[:1]\n", "notes = notes[1:]\n", "#notes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Supression des notes inutiles " ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [], "source": [ "notes = notes[notes[ds_name].notnull()]" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [], "source": [ "notes = notes.astype(float)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Liste des exercices (donc notés)" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [], "source": [ "list_exo = [\"Exercice 1\", \"Exercice 2\", \"Exercice 3\"]" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "collapsed": false }, "outputs": [], "source": [ "notes[list_exo] = notes[list_exo].applymap(lambda x:round(x,2))\n", "#notes[list_exo]" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def toRepVal(val):\n", " if pd.isnull(val):\n", " return \"\\\\NoRep\"\n", " elif val == 0:\n", " return \"\\\\RepZ\"\n", " elif val == 1:\n", " return \"\\\\RepU\"\n", " elif val == 2:\n", " return \"\\\\RepD\"\n", " elif val == 3:\n", " return \"\\\\RepT\"\n", " else:\n", " return val" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "Index(['DM_0504', 'Malus', 'Exercice 1', '1.1.a (domaines)', '1.1.b (Dérivée)',\n", " '1.1.c (Variations)', '1.2.a (domaines)', '1.2.b (Dérivée)',\n", " '1.2.c (Variations)', '1.3.a (Courbe)', '1.3.b (Intersection)',\n", " '1.3.c (Resolution graphique)', '1 Malus', 'Exercice 2',\n", " '2.1 (variations)', '2.2.a (Equation tangente)',\n", " '2.2.b (Position tangente)', '2.2.c (Courbe)', 'Exercice 3',\n", " '3.1 (domaines)', '3.2 (variations)'],\n", " dtype='object')" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "notes.T.index" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "['1.1.a (domaines)',\n", " '1.1.b (Dérivée)',\n", " '1.1.c (Variations)',\n", " '1.2.a (domaines)',\n", " '1.2.b (Dérivée)',\n", " '1.2.c (Variations)',\n", " '1.3.a (Courbe)',\n", " '1.3.b (Intersection)',\n", " '1.3.c (Resolution graphique)',\n", " '2.1 (variations)',\n", " '2.2.a (Equation tangente)',\n", " '2.2.b (Position tangente)',\n", " '2.2.c (Courbe)',\n", " '3.1 (domaines)',\n", " '3.2 (variations)']" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "item_avec_note = list_exo + [ds_name, \"1 Malus\", \"Malus\"]\n", "sous_exo = [i for i in notes.T.index if i not in item_avec_note]\n", "sous_exo" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/lafrite/.virtualenvs/enseignement/lib/python3.4/site-packages/pandas/core/frame.py:2142: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", " self[k1] = value[k2]\n" ] } ], "source": [ "notes[sous_exo] = notes[sous_exo].applymap(toRepVal)\n", "notes[item_avec_note] = notes[item_avec_note].fillna(\".\")\n", "#notes" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "21" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(notes.T.index)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Preparation du fichier .tex" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "collapsed": false }, "outputs": [], "source": [ "bilan = texenv.get_template(\"tpl_bilan.tex\")\n", "with open(\"./bilan.tex\",\"w\") as f:\n", " f.write(bilan.render(eleves = notes, barem = barem, ds_name = ds_name, latex_info = latex_info, nbr_questions = len(barem.T)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Un peu de statistiques" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "count 30.000000\n", "mean 11.016667\n", "std 5.414672\n", "min 0.000000\n", "25% 8.375000\n", "50% 12.250000\n", "75% 14.500000\n", "max 19.500000\n", "Name: DM_0504, dtype: float64" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "notes[ds_name].describe()" ] }, { "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", "version": "3.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }