Skip to content

Instantly share code, notes, and snippets.

@andrewreece
Last active December 12, 2015 16:54
Show Gist options
  • Save andrewreece/e9b37a8c1cd06591cdd4 to your computer and use it in GitHub Desktop.
Save andrewreece/e9b37a8c1cd06591cdd4 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 250,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr>\n",
" <th></th>\n",
" <th></th>\n",
" <th colspan=\"4\" halign=\"left\">code</th>\n",
" <th colspan=\"4\" halign=\"left\">idea</th>\n",
" <th colspan=\"4\" halign=\"left\">prep</th>\n",
" <th colspan=\"4\" halign=\"left\">respect</th>\n",
" </tr>\n",
" <tr>\n",
" <th></th>\n",
" <th></th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" <th>mean</th>\n",
" <th>std</th>\n",
" <th>min</th>\n",
" <th>max</th>\n",
" </tr>\n",
" <tr>\n",
" <th>team</th>\n",
" <th>name</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"4\" valign=\"top\">AABJ</th>\n",
" <th>adnanzaib</th>\n",
" <td>4.333333</td>\n",
" <td>1.154701</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.333333</td>\n",
" <td>1.154701</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.333333</td>\n",
" <td>1.154701</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>aidizhang</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>arroyobrian</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.333333</td>\n",
" <td>1.154701</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>john12wang</th>\n",
" <td>4.333333</td>\n",
" <td>1.154701</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"4\" valign=\"top\">Adele</th>\n",
" <th>a-steel</th>\n",
" <td>3.333333</td>\n",
" <td>0.577350</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>3.666667</td>\n",
" <td>0.577350</td>\n",
" <td>3</td>\n",
" <td>4</td>\n",
" <td>4.000000</td>\n",
" <td>1.000000</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.333333</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>jdongharvard</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.000000</td>\n",
" <td>0.000000</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>4.333333</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>jessicajyli</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.333333</td>\n",
" <td>1.154701</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>starbro</th>\n",
" <td>4.333333</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"4\" valign=\"top\">The Viruses</th>\n",
" <th>belindazeng</th>\n",
" <td>4.500000</td>\n",
" <td>0.707107</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.000000</td>\n",
" <td>1.414214</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.500000</td>\n",
" <td>0.707107</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>moue</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.500000</td>\n",
" <td>0.707107</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.500000</td>\n",
" <td>0.707107</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.500000</td>\n",
" <td>0.707107</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>roseannefeng</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>zahramahmood</th>\n",
" <td>1.000000</td>\n",
" <td>0.000000</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>4.333333</td>\n",
" <td>1.154701</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.000000</td>\n",
" <td>1.000000</td>\n",
" <td>3</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"4\" valign=\"top\">Trumpline Bling</th>\n",
" <th>camillecs</th>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>joannaguth</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>rneuman</th>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.333333</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>segraham24</th>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" <td>5.000000</td>\n",
" <td>0.000000</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>4.666667</td>\n",
" <td>0.577350</td>\n",
" <td>4</td>\n",
" <td>5</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" code idea \\\n",
" mean std min max mean std \n",
"team name \n",
"AABJ adnanzaib 4.333333 1.154701 3 5 4.333333 1.154701 \n",
" aidizhang 5.000000 0.000000 5 5 5.000000 0.000000 \n",
" arroyobrian 5.000000 0.000000 5 5 4.333333 1.154701 \n",
" john12wang 4.333333 1.154701 3 5 4.666667 0.577350 \n",
"Adele a-steel 3.333333 0.577350 3 4 3.666667 0.577350 \n",
" jdongharvard 5.000000 0.000000 5 5 4.000000 0.000000 \n",
" jessicajyli 5.000000 0.000000 5 5 4.666667 0.577350 \n",
" starbro 4.333333 0.577350 4 5 4.666667 0.577350 \n",
"The Viruses belindazeng 4.500000 0.707107 4 5 5.000000 0.000000 \n",
" moue 5.000000 0.000000 5 5 4.500000 0.707107 \n",
" roseannefeng 5.000000 0.000000 5 5 5.000000 0.000000 \n",
" zahramahmood 1.000000 0.000000 1 1 4.333333 1.154701 \n",
"Trumpline Bling camillecs 4.666667 0.577350 4 5 4.666667 0.577350 \n",
" joannaguth 5.000000 0.000000 5 5 4.666667 0.577350 \n",
" rneuman 5.000000 0.000000 5 5 5.000000 0.000000 \n",
" segraham24 4.666667 0.577350 4 5 4.666667 0.577350 \n",
"\n",
" prep respect \\\n",
" min max mean std min max mean \n",
"team name \n",
"AABJ adnanzaib 3 5 4.333333 1.154701 3 5 5.000000 \n",
" aidizhang 5 5 5.000000 0.000000 5 5 5.000000 \n",
" arroyobrian 3 5 4.666667 0.577350 4 5 4.666667 \n",
" john12wang 4 5 4.666667 0.577350 4 5 5.000000 \n",
"Adele a-steel 3 4 4.000000 1.000000 3 5 4.333333 \n",
" jdongharvard 4 4 4.333333 0.577350 4 5 4.666667 \n",
" jessicajyli 4 5 4.333333 1.154701 3 5 4.666667 \n",
" starbro 4 5 4.666667 0.577350 4 5 5.000000 \n",
"The Viruses belindazeng 5 5 4.000000 1.414214 3 5 4.500000 \n",
" moue 4 5 4.500000 0.707107 4 5 4.500000 \n",
" roseannefeng 5 5 5.000000 0.000000 5 5 5.000000 \n",
" zahramahmood 3 5 4.000000 1.000000 3 5 4.666667 \n",
"Trumpline Bling camillecs 4 5 4.666667 0.577350 4 5 5.000000 \n",
" joannaguth 4 5 5.000000 0.000000 5 5 4.666667 \n",
" rneuman 5 5 4.333333 0.577350 4 5 5.000000 \n",
" segraham24 4 5 5.000000 0.000000 5 5 4.666667 \n",
"\n",
" \n",
" std min max \n",
"team name \n",
"AABJ adnanzaib 0.000000 5 5 \n",
" aidizhang 0.000000 5 5 \n",
" arroyobrian 0.577350 4 5 \n",
" john12wang 0.000000 5 5 \n",
"Adele a-steel 0.577350 4 5 \n",
" jdongharvard 0.577350 4 5 \n",
" jessicajyli 0.577350 4 5 \n",
" starbro 0.000000 5 5 \n",
"The Viruses belindazeng 0.707107 4 5 \n",
" moue 0.707107 4 5 \n",
" roseannefeng 0.000000 5 5 \n",
" zahramahmood 0.577350 4 5 \n",
"Trumpline Bling camillecs 0.000000 5 5 \n",
" joannaguth 0.577350 4 5 \n",
" rneuman 0.000000 5 5 \n",
" segraham24 0.577350 4 5 "
]
},
"execution_count": 250,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"''' CS109 Final Project Peer Evaluation Analyzer\n",
" Andrew Reece\n",
" \n",
" This script creates simple descriptive statistics (mean, std, min, max) \n",
" for peer evaluations on final projects. \n",
" \n",
" It produces a dataframe, grouped by team and individual student.\n",
" I've included specifics from my own students as examples - I've noted where you should\n",
" fill in data specific to the teams you're grading.\n",
" \n",
" I renamed the four evaluation categories with summary words, admittedly a bit general:\n",
" \n",
" Preparation for Team Meetings and Timeliness --> prep\n",
" Productive Contribution to Discussion and Idea Generation --> idea\n",
" Contribution to Implementation and Presentation --> code\n",
" Respect for other's ideas and Flexibility when disagreements occured --> respect\n",
"'''\n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"import re\n",
"\n",
"''' NOTE: There is a little bit of data cleaning you need to do before you can use this script\n",
" 1. Do not delete any columns in the spreadsheet.\n",
" 2. Make sure all the members in each team have entered exactly the same team name.\n",
" 2. Collect a list of github ids for all the students in all your groups \n",
"'''\n",
"\n",
"# mystu is the list of github ids for all the students in all your groups\n",
"mystu = [\"adnanzaib\",\"john12wang\",\"arroyobrian\",\"aidizhang\",\"jdongharvard\",\"starbro\",\"a-steel\",\"jessicajyli\",\"belindazeng\",\"roseannefeng\",\"moue\",\"joannaguth\",\"rneuman\",\"camillecs\",\"segraham24\"]\n",
"\n",
"# this is the downloaded google spreadsheet\n",
"# call it what you want but make sure the path is correct\n",
"fname = \"project_spreadsheet.tsv\"\n",
"\n",
"# i used tsv but csv should work too ...in case of csv change delimiter=\",\"\n",
"delimiter = \"\\t\"\n",
"\n",
"original = pd.read_csv(fname, sep=delimiter)\n",
"\n",
"# get rid of garbage columns (very hacky regex)\n",
"df = original.filter(regex=re.compile(\"^(?!.+ollaborator\\s1|\\s\\\\[Row|unnamed|Your other)\",re.IGNORECASE))\n",
"\n",
"# rename columns for easier pandas-fu - you don't need to do anything here\n",
"new_cols = [u'Timestamp', u'm0_name', u'x_team', u'project_name', u'website',\n",
" u'screencast', u'repo', u'm0_prep', u'm0_idea', u'm0_code',\n",
" u'm0_respect',u'm1_name', u'm1_prep', u'm1_idea', u'm1_code',\n",
" u'm1_respect',u'm2_name',u'm3_name', u'm2_prep', u'm2_idea',\n",
" u'm2_code', u'm2_respect', u'm3_prep',\n",
" u'm3_idea', u'm3_code', u'm3_respect', u'm2_extra', u'm3_extra', u'm1_extra']\n",
"df.columns = new_cols\n",
"\n",
"# narrow down to only your students\n",
"df = df.ix[df.m0_name.str.strip().isin(mystu),:].reset_index(drop=True)\n",
"\n",
"# take only rows for peer evaluation\n",
"members = df.filter(regex=\"^m|x_team\")\n",
"\n",
"# chop up df so we can group by name\n",
"stacked_dict = {}\n",
"stacked_df = pd.DataFrame()\n",
"\n",
"# this ignores self-evaluation! it only looks at what teammates thought of someone.\n",
"for i in range(1,4):\n",
" mid = 'm{}'.format(i)\n",
" stacked_dict[mid] = members.filter(regex=\"^x_team|\"+mid)\n",
" stacked_dict[mid].columns = [col.split(\"_\")[1] for col in stacked_dict[mid].columns]\n",
" stacked_df = pd.concat([stacked_df,stacked_dict[mid]],0)\n",
" \n",
"# now group by team and then individual \n",
"grouped = stacked_df.groupby([\"team\",\"name\"])\n",
"\n",
"# compute summary statistics for each person\n",
"grouped['code','idea','prep','respect'].agg([np.mean,np.std,min,max])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment