Commit cce9e61d by Prayush Kumar

Allocation by lottery of incoming first years

parent d87f2326
# Name,Housing Allocation Num,Housing Allocation
sangeetha s,0,On campus shared
anjali bhatter,0,On campus shared
sri krithika,1,Hostel 3
elizabeth sara roy,0,On campus shared
kanak sorari,0,On campus shared
saiba ayoub,0,On campus shared
prajwal prakashrao jadhav,1,Hostel 3
saikat bera,0,On campus shared
vamshi krishna talala,1,Hostel 3
arup datta,0,On campus shared
abhinav dhawan,1,Hostel 3
anesh,2,Hostel 5
saikat ghosh,1,Hostel 3
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import random\n",
"import copy\n",
"import datetime\n",
"\n",
"# Set RNG seed using noon time on the day lottery was run\n",
"random.seed(int(datetime.datetime(2024, 7, 25, 12, 0, 0, 0).timestamp()))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Availability and Constraints**\n",
"\n",
"From Veena:\n",
"\n",
"https://docs.google.com/spreadsheets/d/1KAuI6Mgm6qHIX9AN6Z6Ue0pMRwULyJZDhkO-dypCFtc/edit#gid=0\n",
"\n",
"*Postdoctoral fellows receive preference over PhD students for Hostel 1 and Hostel 2 accommodation.*"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"housing_mapping = {\n",
" 0: \"On campus shared\",\n",
" 1: \"Hostel 3\",\n",
" 2: \"Hostel 5\",\n",
"}\n",
"availability = {}\n",
"availability[\"student\"] = {\n",
" 0: 2 + 6 - 1, # shared on campus\n",
" 1: 19, # hostel 3\n",
" 2: 3, # hostel 5\n",
"} # END"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Housing for students"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A few notes before we begin.\n",
"\n",
" - In the first CSV input below, we have preferences from last year students and 2 postdocs. The postdocs were automatically allotted their first preferences as there was vacancy and they are categorically preferred for allocation over students. Therefore we will drop the entries corresponding to the 2 postdocs.\n",
" - In the second CSV input below, we have preferences from first year students. However the female students have been pre-allotted on-campus housing given their preference for it, and we will only perform allocation for the remaining students here."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"input_csv1 = \"./2024_leftovers_Hostel Preference - Sheet1.csv\"\n",
"raw_responses1 = pd.read_csv(input_csv1)\n",
"\n",
"input_csv2 = \"./Housing allotment request form- First year students (2024) (Responses) - Form Responses 1.csv\"\n",
"raw_responses2 = pd.read_csv(input_csv2)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Year of Study</th>\n",
" <th>Hostel 2\\n(Vacancy = 1)</th>\n",
" <th>Hostel 3\\n(Vacancy = 19)</th>\n",
" <th>Hostel 4\\n(Vacancy =1)</th>\n",
" <th>Hostel 5\\n(Vacancy = 3)</th>\n",
" <th>Unnamed: 6</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Asrat Demisē</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>PDF</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Jitendra Kethepalli</td>\n",
" <td>NaN</td>\n",
" <td>2</td>\n",
" <td>1.0</td>\n",
" <td>3.0</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Tushar Mondal</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" <td>2.0</td>\n",
" <td>4.0</td>\n",
" <td>PDF</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Anup Gupta</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Soummyadip Basak</td>\n",
" <td>7.0</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" <td>2.0</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Basudeb Mondal</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" <td>2.0</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Year of Study Hostel 2\\n(Vacancy = 1) \\\n",
"0 Asrat Demisē NaN 1 \n",
"1 Jitendra Kethepalli NaN 2 \n",
"2 Tushar Mondal NaN 1 \n",
"3 Anup Gupta NaN 1 \n",
"4 Soummyadip Basak 7.0 1 \n",
"5 Basudeb Mondal NaN 1 \n",
"\n",
" Hostel 3\\n(Vacancy = 19) Hostel 4\\n(Vacancy =1) Hostel 5\\n(Vacancy = 3) \\\n",
"0 NaN NaN NaN \n",
"1 1.0 3.0 4.0 \n",
"2 3.0 2.0 4.0 \n",
"3 NaN NaN NaN \n",
"4 3.0 2.0 4.0 \n",
"5 3.0 2.0 4.0 \n",
"\n",
" Unnamed: 6 \n",
"0 PDF \n",
"1 NaN \n",
"2 PDF \n",
"3 NaN \n",
"4 NaN \n",
"5 NaN "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"raw_responses1"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Year of Study</th>\n",
" <th>Hostel 2\\n(Vacancy = 1)</th>\n",
" <th>Hostel 3\\n(Vacancy = 19)</th>\n",
" <th>Hostel 4\\n(Vacancy =1)</th>\n",
" <th>Hostel 5\\n(Vacancy = 3)</th>\n",
" <th>Unnamed: 6</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Jitendra Kethepalli</td>\n",
" <td>NaN</td>\n",
" <td>2</td>\n",
" <td>1.0</td>\n",
" <td>3.0</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Anup Gupta</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Soummyadip Basak</td>\n",
" <td>7.0</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" <td>2.0</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Basudeb Mondal</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" <td>2.0</td>\n",
" <td>4.0</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Year of Study Hostel 2\\n(Vacancy = 1) \\\n",
"1 Jitendra Kethepalli NaN 2 \n",
"3 Anup Gupta NaN 1 \n",
"4 Soummyadip Basak 7.0 1 \n",
"5 Basudeb Mondal NaN 1 \n",
"\n",
" Hostel 3\\n(Vacancy = 19) Hostel 4\\n(Vacancy =1) Hostel 5\\n(Vacancy = 3) \\\n",
"1 1.0 3.0 4.0 \n",
"3 NaN NaN NaN \n",
"4 3.0 2.0 4.0 \n",
"5 3.0 2.0 4.0 \n",
"\n",
" Unnamed: 6 \n",
"1 NaN \n",
"3 NaN \n",
"4 NaN \n",
"5 NaN "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"raw_responses1 = raw_responses1.drop([0, 2])\n",
"raw_responses1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"WE realize immediately that since hostels 2 and 4 have no vacancies,\n",
" - Jitendra, Soummyadip and Basudeb will all get hostel 3 (which is their next choice after hostels 2 and 4). \n",
" - Remaining student Anup can also be allotted hostel 3 because they have not given any preference after hostel 2, so we just allot whatever hostel has more rooms free."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"raw_responses = raw_responses2"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Timestamp</th>\n",
" <th>Email Address</th>\n",
" <th>Name</th>\n",
" <th>Program enrolled</th>\n",
" <th>Year of Study</th>\n",
" <th>Are you a female student?</th>\n",
" <th>Please indicate your order of preference for campus housing [On-campus accommodation]</th>\n",
" <th>Please indicate your order of preference for campus housing [Hostel 3]</th>\n",
" <th>Please indicate your order of preference for campus housing [Hostel 5]</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>6/24/2024 17:16:20</td>\n",
" <td>kanaksorari50@gmail.com</td>\n",
" <td>Kanak Sorari</td>\n",
" <td>IPhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>6/24/2024 17:17:49</td>\n",
" <td>srihari.talala@gmail.com</td>\n",
" <td>Vamshi Krishna Talala</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>2.0</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>6/24/2024 18:36:07</td>\n",
" <td>vsrikrithika@gmail.com</td>\n",
" <td>Sri Krithika</td>\n",
" <td>IPhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>NaN</td>\n",
" <td>1</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>6/24/2024 18:47:24</td>\n",
" <td>saikatb.physics@gmail.com</td>\n",
" <td>Saikat Bera</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>6/24/2024 18:57:56</td>\n",
" <td>aneshbishnoi0001@gmail.com</td>\n",
" <td>Anesh</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>6/24/2024 19:37:26</td>\n",
" <td>abhinavdhawan147@gmail.com</td>\n",
" <td>Abhinav Dhawan</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>6/24/2024 19:49:54</td>\n",
" <td>gsaikat2022@gmail.com</td>\n",
" <td>Saikat Ghosh</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>6/24/2024 20:32:17</td>\n",
" <td>sangeethas1729@gmail.com</td>\n",
" <td>Sangeetha S</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>6/25/2024 8:00:16</td>\n",
" <td>elizabethsararoy@gmail.com</td>\n",
" <td>Elizabeth Sara Roy</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>6/30/2024 20:30:11</td>\n",
" <td>arupdatta1.618@gmail.com</td>\n",
" <td>ARUP DATTA</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>6/26/2024 12:19:21</td>\n",
" <td>saibaayoub1@gmail.com</td>\n",
" <td>Saiba Ayoub</td>\n",
" <td>IPhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>6/26/2024 22:25:13</td>\n",
" <td>prajwaljadhav5183@gmail.com</td>\n",
" <td>Prajwal Prakashrao Jadhav</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>2.0</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>6/28/2024 5:44:39</td>\n",
" <td>bhatteranjali6@gmail.com</td>\n",
" <td>Anjali Bhatter</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Timestamp Email Address \\\n",
"0 6/24/2024 17:16:20 kanaksorari50@gmail.com \n",
"1 6/24/2024 17:17:49 srihari.talala@gmail.com \n",
"2 6/24/2024 18:36:07 vsrikrithika@gmail.com \n",
"3 6/24/2024 18:47:24 saikatb.physics@gmail.com \n",
"4 6/24/2024 18:57:56 aneshbishnoi0001@gmail.com \n",
"5 6/24/2024 19:37:26 abhinavdhawan147@gmail.com \n",
"6 6/24/2024 19:49:54 gsaikat2022@gmail.com \n",
"7 6/24/2024 20:32:17 sangeethas1729@gmail.com \n",
"8 6/25/2024 8:00:16 elizabethsararoy@gmail.com \n",
"9 6/30/2024 20:30:11 arupdatta1.618@gmail.com \n",
"10 6/26/2024 12:19:21 saibaayoub1@gmail.com \n",
"11 6/26/2024 22:25:13 prajwaljadhav5183@gmail.com \n",
"12 6/28/2024 5:44:39 bhatteranjali6@gmail.com \n",
"\n",
" Name Program enrolled Year of Study \\\n",
"0 Kanak Sorari IPhD First year \n",
"1 Vamshi Krishna Talala PhD First year \n",
"2 Sri Krithika IPhD First year \n",
"3 Saikat Bera PhD First year \n",
"4 Anesh PhD First year \n",
"5 Abhinav Dhawan PhD First year \n",
"6 Saikat Ghosh PhD First year \n",
"7 Sangeetha S PhD First year \n",
"8 Elizabeth Sara Roy PhD First year \n",
"9 ARUP DATTA PhD First year \n",
"10 Saiba Ayoub IPhD First year \n",
"11 Prajwal Prakashrao Jadhav PhD First year \n",
"12 Anjali Bhatter PhD First year \n",
"\n",
" Are you a female student? \\\n",
"0 Yes \n",
"1 No \n",
"2 Yes \n",
"3 No \n",
"4 No \n",
"5 No \n",
"6 No \n",
"7 Yes \n",
"8 Yes \n",
"9 No \n",
"10 Yes \n",
"11 No \n",
"12 Yes \n",
"\n",
" Please indicate your order of preference for campus housing [On-campus accommodation] \\\n",
"0 1.0 \n",
"1 2.0 \n",
"2 NaN \n",
"3 1.0 \n",
"4 1.0 \n",
"5 1.0 \n",
"6 1.0 \n",
"7 1.0 \n",
"8 1.0 \n",
"9 1.0 \n",
"10 1.0 \n",
"11 2.0 \n",
"12 1.0 \n",
"\n",
" Please indicate your order of preference for campus housing [Hostel 3] \\\n",
"0 3 \n",
"1 1 \n",
"2 1 \n",
"3 2 \n",
"4 3 \n",
"5 2 \n",
"6 2 \n",
"7 3 \n",
"8 2 \n",
"9 2 \n",
"10 3 \n",
"11 1 \n",
"12 3 \n",
"\n",
" Please indicate your order of preference for campus housing [Hostel 5] \n",
"0 2.0 \n",
"1 3.0 \n",
"2 NaN \n",
"3 3.0 \n",
"4 2.0 \n",
"5 3.0 \n",
"6 3.0 \n",
"7 2.0 \n",
"8 3.0 \n",
"9 3.0 \n",
"10 2.0 \n",
"11 3.0 \n",
"12 2.0 "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"raw_responses"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# Replacing empty entries with a constant number that is large enough,\n",
"# This amounts to treating those choices for which students have filled\n",
"# no preferences as being equally preferred by them\n",
"nan_value = 99\n",
"proc_responses = raw_responses.replace(np.nan, nan_value)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Timestamp</th>\n",
" <th>Email Address</th>\n",
" <th>Name</th>\n",
" <th>Program enrolled</th>\n",
" <th>Year of Study</th>\n",
" <th>Are you a female student?</th>\n",
" <th>Please indicate your order of preference for campus housing [On-campus accommodation]</th>\n",
" <th>Please indicate your order of preference for campus housing [Hostel 3]</th>\n",
" <th>Please indicate your order of preference for campus housing [Hostel 5]</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>6/24/2024 17:16:20</td>\n",
" <td>kanaksorari50@gmail.com</td>\n",
" <td>Kanak Sorari</td>\n",
" <td>IPhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>6/24/2024 17:17:49</td>\n",
" <td>srihari.talala@gmail.com</td>\n",
" <td>Vamshi Krishna Talala</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>2.0</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>6/24/2024 18:36:07</td>\n",
" <td>vsrikrithika@gmail.com</td>\n",
" <td>Sri Krithika</td>\n",
" <td>IPhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>99.0</td>\n",
" <td>1</td>\n",
" <td>99.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>6/24/2024 18:47:24</td>\n",
" <td>saikatb.physics@gmail.com</td>\n",
" <td>Saikat Bera</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>6/24/2024 18:57:56</td>\n",
" <td>aneshbishnoi0001@gmail.com</td>\n",
" <td>Anesh</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>6/24/2024 19:37:26</td>\n",
" <td>abhinavdhawan147@gmail.com</td>\n",
" <td>Abhinav Dhawan</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>6/24/2024 19:49:54</td>\n",
" <td>gsaikat2022@gmail.com</td>\n",
" <td>Saikat Ghosh</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>6/24/2024 20:32:17</td>\n",
" <td>sangeethas1729@gmail.com</td>\n",
" <td>Sangeetha S</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>6/25/2024 8:00:16</td>\n",
" <td>elizabethsararoy@gmail.com</td>\n",
" <td>Elizabeth Sara Roy</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>6/30/2024 20:30:11</td>\n",
" <td>arupdatta1.618@gmail.com</td>\n",
" <td>ARUP DATTA</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>1.0</td>\n",
" <td>2</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>6/26/2024 12:19:21</td>\n",
" <td>saibaayoub1@gmail.com</td>\n",
" <td>Saiba Ayoub</td>\n",
" <td>IPhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>6/26/2024 22:25:13</td>\n",
" <td>prajwaljadhav5183@gmail.com</td>\n",
" <td>Prajwal Prakashrao Jadhav</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>No</td>\n",
" <td>2.0</td>\n",
" <td>1</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>6/28/2024 5:44:39</td>\n",
" <td>bhatteranjali6@gmail.com</td>\n",
" <td>Anjali Bhatter</td>\n",
" <td>PhD</td>\n",
" <td>First year</td>\n",
" <td>Yes</td>\n",
" <td>1.0</td>\n",
" <td>3</td>\n",
" <td>2.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Timestamp Email Address \\\n",
"0 6/24/2024 17:16:20 kanaksorari50@gmail.com \n",
"1 6/24/2024 17:17:49 srihari.talala@gmail.com \n",
"2 6/24/2024 18:36:07 vsrikrithika@gmail.com \n",
"3 6/24/2024 18:47:24 saikatb.physics@gmail.com \n",
"4 6/24/2024 18:57:56 aneshbishnoi0001@gmail.com \n",
"5 6/24/2024 19:37:26 abhinavdhawan147@gmail.com \n",
"6 6/24/2024 19:49:54 gsaikat2022@gmail.com \n",
"7 6/24/2024 20:32:17 sangeethas1729@gmail.com \n",
"8 6/25/2024 8:00:16 elizabethsararoy@gmail.com \n",
"9 6/30/2024 20:30:11 arupdatta1.618@gmail.com \n",
"10 6/26/2024 12:19:21 saibaayoub1@gmail.com \n",
"11 6/26/2024 22:25:13 prajwaljadhav5183@gmail.com \n",
"12 6/28/2024 5:44:39 bhatteranjali6@gmail.com \n",
"\n",
" Name Program enrolled Year of Study \\\n",
"0 Kanak Sorari IPhD First year \n",
"1 Vamshi Krishna Talala PhD First year \n",
"2 Sri Krithika IPhD First year \n",
"3 Saikat Bera PhD First year \n",
"4 Anesh PhD First year \n",
"5 Abhinav Dhawan PhD First year \n",
"6 Saikat Ghosh PhD First year \n",
"7 Sangeetha S PhD First year \n",
"8 Elizabeth Sara Roy PhD First year \n",
"9 ARUP DATTA PhD First year \n",
"10 Saiba Ayoub IPhD First year \n",
"11 Prajwal Prakashrao Jadhav PhD First year \n",
"12 Anjali Bhatter PhD First year \n",
"\n",
" Are you a female student? \\\n",
"0 Yes \n",
"1 No \n",
"2 Yes \n",
"3 No \n",
"4 No \n",
"5 No \n",
"6 No \n",
"7 Yes \n",
"8 Yes \n",
"9 No \n",
"10 Yes \n",
"11 No \n",
"12 Yes \n",
"\n",
" Please indicate your order of preference for campus housing [On-campus accommodation] \\\n",
"0 1.0 \n",
"1 2.0 \n",
"2 99.0 \n",
"3 1.0 \n",
"4 1.0 \n",
"5 1.0 \n",
"6 1.0 \n",
"7 1.0 \n",
"8 1.0 \n",
"9 1.0 \n",
"10 1.0 \n",
"11 2.0 \n",
"12 1.0 \n",
"\n",
" Please indicate your order of preference for campus housing [Hostel 3] \\\n",
"0 3 \n",
"1 1 \n",
"2 1 \n",
"3 2 \n",
"4 3 \n",
"5 2 \n",
"6 2 \n",
"7 3 \n",
"8 2 \n",
"9 2 \n",
"10 3 \n",
"11 1 \n",
"12 3 \n",
"\n",
" Please indicate your order of preference for campus housing [Hostel 5] \n",
"0 2.0 \n",
"1 3.0 \n",
"2 99.0 \n",
"3 3.0 \n",
"4 2.0 \n",
"5 3.0 \n",
"6 3.0 \n",
"7 2.0 \n",
"8 3.0 \n",
"9 3.0 \n",
"10 2.0 \n",
"11 3.0 \n",
"12 2.0 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"proc_responses"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 Timestamp\n",
"1 Email Address\n",
"2 Name\n",
"3 Program enrolled\n",
"4 Year of Study\n",
"5 Are you a female student?\n",
"6 Please indicate your order of preference for campus housing [On-campus accommodation]\n",
"7 Please indicate your order of preference for campus housing [Hostel 3]\n",
"8 Please indicate your order of preference for campus housing [Hostel 5]\n"
]
}
],
"source": [
"# Standardizing column names to be used in rest of the notebook\n",
"for idx, cname in enumerate(proc_responses.columns):\n",
" print(idx, cname)\n",
"\n",
"col_names = list(proc_responses.columns)\n",
"\n",
"proc_responses = proc_responses.rename(\n",
" columns={\n",
" col_names[1]: \"email\",\n",
" col_names[2]: \"name\",\n",
" col_names[3]: \"course\",\n",
" col_names[4]: \"year\",\n",
" col_names[5]: \"female\",\n",
" col_names[6]: \"housing0\",\n",
" col_names[7]: \"housing3\",\n",
" col_names[8]: \"housing5\",\n",
" }\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# Combine the preference order for every person into a single list,\n",
"# as is needed by stuff below, and add it as a new column\n",
"new_col = []\n",
"for idx in range(len(proc_responses)):\n",
" new_col.append(\n",
" list(\n",
" np.array(\n",
" proc_responses[\n",
" [\n",
" \"housing0\",\n",
" \"housing3\",\n",
" \"housing5\",\n",
" ]\n",
" ]\n",
" .iloc[idx]\n",
" .to_list()\n",
" ).astype(\"int\")\n",
" )\n",
" )\n",
"\n",
"proc_responses[\"housing_ranking\"] = new_col\n",
"\n",
"\n",
"preferences = []\n",
"for input_pref in new_col:\n",
" pref_order = [-1] * len(input_pref)\n",
" for idx, val in enumerate(input_pref):\n",
" if val <= len(input_pref):\n",
" pref_order[val - 1] = idx\n",
"\n",
" for idx, val in enumerate(input_pref):\n",
" if val > len(input_pref):\n",
" pref_order[len(pref_order) - 1 - pref_order[::-1].index(-1)] = idx\n",
"\n",
" preferences.append(pref_order)\n",
"\n",
"\n",
"proc_responses[\"preferences\"] = preferences"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"# Since everyone here is a student\n",
"proc_responses[\"student_or_postdoc\"] = [\"student\"] * len(proc_responses)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"# Replace gender responses from English to integers\n",
"numeric_response = []\n",
"for x in proc_responses[\"female\"].to_list():\n",
" if type(x) is int:\n",
" numeric_response.append(0) # blank -> Nan -> 99 -> 0\n",
" elif x.lower() == \"yes\":\n",
" numeric_response.append(1)\n",
" else:\n",
" numeric_response.append(0)\n",
"proc_responses[\"female\"] = numeric_response"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"# Replace year of study response from English to integers\n",
"new_col = []\n",
"for r in proc_responses[\"year\"].to_list():\n",
" r = str(r)\n",
" if \"first\" in r.lower():\n",
" new_col.append(1)\n",
" elif \"second\" in r.lower():\n",
" new_col.append(2)\n",
" elif \"third\" in r.lower():\n",
" new_col.append(3)\n",
" elif \"fourth\" in r.lower():\n",
" new_col.append(4)\n",
" elif \"fifth\" in r.lower():\n",
" new_col.append(5)\n",
" elif \"sixth\" in r.lower():\n",
" new_col.append(6)\n",
" elif \"seven\" in r.lower():\n",
" new_col.append(7)\n",
" else:\n",
" print(f\"Whoa - weird response for year of study: {r}\")\n",
" new_col.append(-1)\n",
"proc_responses[\"year\"] = np.asarray(new_col) + 0\n",
"# NOTE: As we run lottery in May 2024, academic year has not changed, so we\n",
"# need to add 1 to everyone's year."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"# Remove columns that we do not need going forward\n",
"final_responses = proc_responses[\n",
" [\n",
" \"email\",\n",
" \"name\",\n",
" \"year\",\n",
" \"course\",\n",
" \"female\",\n",
" \"preferences\",\n",
" \"student_or_postdoc\",\n",
" \"housing_ranking\",\n",
" ]\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>email</th>\n",
" <th>name</th>\n",
" <th>year</th>\n",
" <th>course</th>\n",
" <th>female</th>\n",
" <th>preferences</th>\n",
" <th>student_or_postdoc</th>\n",
" <th>housing_ranking</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>kanaksorari50@gmail.com</td>\n",
" <td>Kanak Sorari</td>\n",
" <td>1</td>\n",
" <td>IPhD</td>\n",
" <td>1</td>\n",
" <td>[0, 2, 1]</td>\n",
" <td>student</td>\n",
" <td>[1, 3, 2]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>srihari.talala@gmail.com</td>\n",
" <td>Vamshi Krishna Talala</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>0</td>\n",
" <td>[1, 0, 2]</td>\n",
" <td>student</td>\n",
" <td>[2, 1, 3]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>vsrikrithika@gmail.com</td>\n",
" <td>Sri Krithika</td>\n",
" <td>1</td>\n",
" <td>IPhD</td>\n",
" <td>1</td>\n",
" <td>[1, 2, 0]</td>\n",
" <td>student</td>\n",
" <td>[99, 1, 99]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>saikatb.physics@gmail.com</td>\n",
" <td>Saikat Bera</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>0</td>\n",
" <td>[0, 1, 2]</td>\n",
" <td>student</td>\n",
" <td>[1, 2, 3]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>aneshbishnoi0001@gmail.com</td>\n",
" <td>Anesh</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>0</td>\n",
" <td>[0, 2, 1]</td>\n",
" <td>student</td>\n",
" <td>[1, 3, 2]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>abhinavdhawan147@gmail.com</td>\n",
" <td>Abhinav Dhawan</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>0</td>\n",
" <td>[0, 1, 2]</td>\n",
" <td>student</td>\n",
" <td>[1, 2, 3]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>gsaikat2022@gmail.com</td>\n",
" <td>Saikat Ghosh</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>0</td>\n",
" <td>[0, 1, 2]</td>\n",
" <td>student</td>\n",
" <td>[1, 2, 3]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>sangeethas1729@gmail.com</td>\n",
" <td>Sangeetha S</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>1</td>\n",
" <td>[0, 2, 1]</td>\n",
" <td>student</td>\n",
" <td>[1, 3, 2]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>elizabethsararoy@gmail.com</td>\n",
" <td>Elizabeth Sara Roy</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>1</td>\n",
" <td>[0, 1, 2]</td>\n",
" <td>student</td>\n",
" <td>[1, 2, 3]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>arupdatta1.618@gmail.com</td>\n",
" <td>ARUP DATTA</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>0</td>\n",
" <td>[0, 1, 2]</td>\n",
" <td>student</td>\n",
" <td>[1, 2, 3]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>saibaayoub1@gmail.com</td>\n",
" <td>Saiba Ayoub</td>\n",
" <td>1</td>\n",
" <td>IPhD</td>\n",
" <td>1</td>\n",
" <td>[0, 2, 1]</td>\n",
" <td>student</td>\n",
" <td>[1, 3, 2]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>prajwaljadhav5183@gmail.com</td>\n",
" <td>Prajwal Prakashrao Jadhav</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>0</td>\n",
" <td>[1, 0, 2]</td>\n",
" <td>student</td>\n",
" <td>[2, 1, 3]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>bhatteranjali6@gmail.com</td>\n",
" <td>Anjali Bhatter</td>\n",
" <td>1</td>\n",
" <td>PhD</td>\n",
" <td>1</td>\n",
" <td>[0, 2, 1]</td>\n",
" <td>student</td>\n",
" <td>[1, 3, 2]</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" email name year course \\\n",
"0 kanaksorari50@gmail.com Kanak Sorari 1 IPhD \n",
"1 srihari.talala@gmail.com Vamshi Krishna Talala 1 PhD \n",
"2 vsrikrithika@gmail.com Sri Krithika 1 IPhD \n",
"3 saikatb.physics@gmail.com Saikat Bera 1 PhD \n",
"4 aneshbishnoi0001@gmail.com Anesh 1 PhD \n",
"5 abhinavdhawan147@gmail.com Abhinav Dhawan 1 PhD \n",
"6 gsaikat2022@gmail.com Saikat Ghosh 1 PhD \n",
"7 sangeethas1729@gmail.com Sangeetha S 1 PhD \n",
"8 elizabethsararoy@gmail.com Elizabeth Sara Roy 1 PhD \n",
"9 arupdatta1.618@gmail.com ARUP DATTA 1 PhD \n",
"10 saibaayoub1@gmail.com Saiba Ayoub 1 IPhD \n",
"11 prajwaljadhav5183@gmail.com Prajwal Prakashrao Jadhav 1 PhD \n",
"12 bhatteranjali6@gmail.com Anjali Bhatter 1 PhD \n",
"\n",
" female preferences student_or_postdoc housing_ranking \n",
"0 1 [0, 2, 1] student [1, 3, 2] \n",
"1 0 [1, 0, 2] student [2, 1, 3] \n",
"2 1 [1, 2, 0] student [99, 1, 99] \n",
"3 0 [0, 1, 2] student [1, 2, 3] \n",
"4 0 [0, 2, 1] student [1, 3, 2] \n",
"5 0 [0, 1, 2] student [1, 2, 3] \n",
"6 0 [0, 1, 2] student [1, 2, 3] \n",
"7 1 [0, 2, 1] student [1, 3, 2] \n",
"8 1 [0, 1, 2] student [1, 2, 3] \n",
"9 0 [0, 1, 2] student [1, 2, 3] \n",
"10 1 [0, 2, 1] student [1, 3, 2] \n",
"11 0 [1, 0, 2] student [2, 1, 3] \n",
"12 1 [0, 2, 1] student [1, 3, 2] "
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"final_responses"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" A simple CSV/XLSX file with at least the following columns (it can have additional columns, doesn't matter):\n",
"\n",
" Name, Year of study, Student or Postdoc, Female or not, Preferences, ..\n",
"\n",
" A sample entry would be:\n",
" Albert Einstein, 1, student, no, [0, 1, 2, 3, 4, 5, 6, 8, 7],\n",
"\n",
" Total number of available housing in each category.\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"inputs = final_responses.to_dict(orient=\"list\")"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"for idx in range(len(inputs[\"name\"])):\n",
" inputs[\"name\"][idx] = inputs[\"name\"][idx].lower().strip().replace(\" \", \" \")\n",
" inputs[\"course\"][idx] = inputs[\"course\"][idx].lower().strip()\n",
" inputs[\"email\"][idx] = inputs[\"email\"][idx].lower().strip()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"def get_info_for_person(person_name, col_name):\n",
" if person_name not in inputs[\"name\"]:\n",
" raise IOError(f\"We do not recognize name: {person_name}\")\n",
"\n",
" if col_name not in inputs:\n",
" raise IOError(f\"We were not provided with info: {col_name}\")\n",
"\n",
" idx_of_person = inputs[\"name\"].index(person_name)\n",
" return inputs[col_name][idx_of_person]\n",
"\n",
"\n",
"def get_pool_number_for_student(person_name):\n",
" pool_number = 3\n",
" if (get_info_for_person(person_name, \"female\") == 1) and (\n",
" get_info_for_person(person_name, \"year\") == 1\n",
" ):\n",
" pool_number = 1\n",
" elif (get_info_for_person(person_name, \"year\") == 1) or (\n",
" (\n",
" get_info_for_person(person_name, \"year\") >= 5\n",
" and get_info_for_person(person_name, \"course\").lower() == \"phd\"\n",
" )\n",
" or (\n",
" get_info_for_person(person_name, \"year\") >= 6\n",
" and get_info_for_person(person_name, \"course\").lower() == \"iphd\"\n",
" )\n",
" ):\n",
" pool_number = 2\n",
" return pool_number\n",
"\n",
"\n",
"def get_possible_pools():\n",
" return [1, 2, 3]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_pool_number_for_student(\"anesh\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check if inputs look okay"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Housing preferences for 2, vsrikrithika@gmail.com are repeated: [99, 1, 99]\n",
"Inputs look good. We got 13 entries.\n"
]
}
],
"source": [
"total_number_of_people = len(inputs[\"name\"])\n",
"\n",
"for col_name in inputs:\n",
" if len(inputs[col_name]) != total_number_of_people:\n",
" raise IOError(\n",
" \"There are {} entries for column {}. We need {}.\".format(\n",
" len(inputs[col_name]), col_name, total_number_of_people\n",
" )\n",
" )\n",
" if col_name in [\"name\", \"email\"]:\n",
" if len(set(inputs[col_name])) != total_number_of_people:\n",
" tmp = []\n",
" for em in inputs[col_name]:\n",
" if em not in tmp:\n",
" tmp.append(em)\n",
" else:\n",
" print(f\"In {col_name}: {em} is repeated!\")\n",
" raise IOError(\n",
" \"There are {} UNIQUE entries for column {}. We need {}.\".format(\n",
" len(set(inputs[col_name])), col_name, total_number_of_people\n",
" )\n",
" )\n",
" if col_name in [\"housing_ranking\"]:\n",
" for i, ps in enumerate(inputs[\"housing_ranking\"]):\n",
" if len(ps) != len(set(ps)):\n",
" print(\n",
" f\"Housing preferences for {i}, {inputs['email'][i]} are repeated: {ps}\"\n",
" )\n",
"\n",
"\n",
"print(f\"Inputs look good. We got {total_number_of_people} entries.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Assign people to lottery pools"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"all_pools = {}"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Here are our assignments:\n",
"In pool 1, we have:\n",
" ['kanak sorari', 'sri krithika', 'sangeetha s', 'elizabeth sara roy', 'saiba ayoub', 'anjali bhatter']\n",
"In pool 2, we have:\n",
" ['vamshi krishna talala', 'saikat bera', 'anesh', 'abhinav dhawan', 'saikat ghosh', 'arup datta', 'prajwal prakashrao jadhav']\n",
"In pool 3, we have:\n",
" []\n"
]
}
],
"source": [
"housing_pools = {}\n",
"\n",
"for pool_id in get_possible_pools():\n",
" _pool = []\n",
" for person_name in inputs[\"name\"]:\n",
" # FIXME: Change the next line for postdocs\n",
" if get_info_for_person(person_name, \"student_or_postdoc\") == \"student\":\n",
" if get_pool_number_for_student(person_name) == pool_id:\n",
" _pool.append(person_name)\n",
" housing_pools[pool_id] = _pool\n",
"\n",
"print(\"Here are our assignments:\")\n",
"\n",
"for pool_id in housing_pools:\n",
" print(f\"In pool {pool_id}, we have:\\n {housing_pools[pool_id]}\")\n",
"\n",
"all_pools[\"student\"] = copy.deepcopy(housing_pools)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Draw lottery and assign housing"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"housing_allocations = {}"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"------------------------\n",
"Processing housing allotments for: student\n",
"\n",
"As per a randomized lottery, we will allocate pool 1 in the following order:['sangeetha s', 'anjali bhatter', 'sri krithika', 'elizabeth sara roy', 'kanak sorari', 'saiba ayoub']\n",
"...assigning housing 0 to sangeetha s as it has 7 vacancies still.\n",
"...assigning housing 0 to anjali bhatter as it has 6 vacancies still.\n",
"...assigning housing 1 to sri krithika as it has 19 vacancies still.\n",
"...assigning housing 0 to elizabeth sara roy as it has 5 vacancies still.\n",
"...assigning housing 0 to kanak sorari as it has 4 vacancies still.\n",
"...assigning housing 0 to saiba ayoub as it has 3 vacancies still.\n",
"\n",
"As per a randomized lottery, we will allocate pool 2 in the following order:['prajwal prakashrao jadhav', 'saikat bera', 'vamshi krishna talala', 'arup datta', 'abhinav dhawan', 'anesh', 'saikat ghosh']\n",
"...assigning housing 1 to prajwal prakashrao jadhav as it has 18 vacancies still.\n",
"...assigning housing 0 to saikat bera as it has 2 vacancies still.\n",
"...assigning housing 1 to vamshi krishna talala as it has 17 vacancies still.\n",
"...assigning housing 0 to arup datta as it has 1 vacancies still.\n",
"For abhinav dhawan, acco 0 is full. Moving on...\n",
"...assigning housing 1 to abhinav dhawan as it has 16 vacancies still.\n",
"For anesh, acco 0 is full. Moving on...\n",
"...assigning housing 2 to anesh as it has 3 vacancies still.\n",
"For saikat ghosh, acco 0 is full. Moving on...\n",
"...assigning housing 1 to saikat ghosh as it has 15 vacancies still.\n",
"\n",
"As per a randomized lottery, we will allocate pool 3 in the following order:[]\n",
"------------------------\n"
]
}
],
"source": [
"for pool_type in [\"student\"]:\n",
" print(\"------------------------\")\n",
" print(f\"Processing housing allotments for: {pool_type}\")\n",
" current_availability = copy.deepcopy(availability[pool_type])\n",
" current_pool = all_pools[pool_type]\n",
"\n",
" for pool_id in get_possible_pools():\n",
" # randomly assign ranks, and sort according to it\n",
" this_pool = current_pool[pool_id]\n",
" # print(this_pool)\n",
" random.shuffle(this_pool)\n",
" # print(this_pool)\n",
"\n",
" print(\n",
" f\"\\nAs per a randomized lottery, we will allocate pool {pool_id} in the following order:\"\n",
" f\"{this_pool}\"\n",
" )\n",
"\n",
" # now we go over the ranked list, and assign housing based on availability\n",
" for person_name in this_pool:\n",
" their_preferences = get_info_for_person(person_name, \"preferences\")\n",
" for pref in their_preferences:\n",
" if current_availability[pref] > 0:\n",
" # Allot NOW!\n",
" print(\n",
" f\"\"\"...assigning housing {pref} to {\n",
" person_name} as it has {\n",
" current_availability[pref]} vacancies still.\"\"\"\n",
" )\n",
" housing_allocations[person_name] = pref\n",
" current_availability[pref] = current_availability[pref] - 1\n",
" break\n",
" else:\n",
" print(f\"For {person_name}, acco {pref} is full. Moving on...\")\n",
" continue\n",
" print(\"------------------------\")"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'sangeetha s': 0,\n",
" 'anjali bhatter': 0,\n",
" 'sri krithika': 1,\n",
" 'elizabeth sara roy': 0,\n",
" 'kanak sorari': 0,\n",
" 'saiba ayoub': 0,\n",
" 'prajwal prakashrao jadhav': 1,\n",
" 'saikat bera': 0,\n",
" 'vamshi krishna talala': 1,\n",
" 'arup datta': 0,\n",
" 'abhinav dhawan': 1,\n",
" 'anesh': 2,\n",
" 'saikat ghosh': 1}"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"housing_allocations"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"with open(\"2024__first_year_student_housing_allocations.txt\", \"w\") as fout:\n",
" fout.write(f\"# Name,Housing Allocation Num,Housing Allocation\\n\")\n",
" for name in housing_allocations:\n",
" fout.write(\n",
" f\"{name},{housing_allocations[name]},{housing_mapping[housing_allocations[name]]}\\n\"\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th># Name</th>\n",
" <th>Housing Allocation Num</th>\n",
" <th>Housing Allocation</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>sangeetha s</td>\n",
" <td>0</td>\n",
" <td>On campus shared</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>anjali bhatter</td>\n",
" <td>0</td>\n",
" <td>On campus shared</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>sri krithika</td>\n",
" <td>1</td>\n",
" <td>Hostel 3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>elizabeth sara roy</td>\n",
" <td>0</td>\n",
" <td>On campus shared</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>kanak sorari</td>\n",
" <td>0</td>\n",
" <td>On campus shared</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>saiba ayoub</td>\n",
" <td>0</td>\n",
" <td>On campus shared</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>prajwal prakashrao jadhav</td>\n",
" <td>1</td>\n",
" <td>Hostel 3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>saikat bera</td>\n",
" <td>0</td>\n",
" <td>On campus shared</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>vamshi krishna talala</td>\n",
" <td>1</td>\n",
" <td>Hostel 3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>arup datta</td>\n",
" <td>0</td>\n",
" <td>On campus shared</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>abhinav dhawan</td>\n",
" <td>1</td>\n",
" <td>Hostel 3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>anesh</td>\n",
" <td>2</td>\n",
" <td>Hostel 5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>saikat ghosh</td>\n",
" <td>1</td>\n",
" <td>Hostel 3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" # Name Housing Allocation Num Housing Allocation\n",
"0 sangeetha s 0 On campus shared\n",
"1 anjali bhatter 0 On campus shared\n",
"2 sri krithika 1 Hostel 3\n",
"3 elizabeth sara roy 0 On campus shared\n",
"4 kanak sorari 0 On campus shared\n",
"5 saiba ayoub 0 On campus shared\n",
"6 prajwal prakashrao jadhav 1 Hostel 3\n",
"7 saikat bera 0 On campus shared\n",
"8 vamshi krishna talala 1 Hostel 3\n",
"9 arup datta 0 On campus shared\n",
"10 abhinav dhawan 1 Hostel 3\n",
"11 anesh 2 Hostel 5\n",
"12 saikat ghosh 1 Hostel 3"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.set_option(\"display.max_rows\", None)\n",
"pd.read_csv(\"2024__first_year_student_housing_allocations.txt\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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.8.16"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Name,Year of Study,"Hostel 2
(Vacancy = 1)","Hostel 3
(Vacancy = 19)","Hostel 4
(Vacancy =1)","Hostel 5
(Vacancy = 3)",
Asrat Demisē,,1,,,,PDF
Jitendra Kethepalli,,2,1,3,4,
Tushar Mondal,,1,3,2,4,PDF
Anup Gupta,,1,,,,
Soummyadip Basak,7,1,3,2,4,
Basudeb Mondal,,1,3,2,4,
\ No newline at end of file
Timestamp,Email Address,Name,Program enrolled,Year of Study,Are you a female student?,Please indicate your order of preference for campus housing [On-campus accommodation],Please indicate your order of preference for campus housing [Hostel 3],Please indicate your order of preference for campus housing [Hostel 5]
6/24/2024 17:16:20,kanaksorari50@gmail.com,Kanak Sorari,IPhD,First year,Yes,1,3,2
6/24/2024 17:17:49,srihari.talala@gmail.com,Vamshi Krishna Talala,PhD,First year,No,2,1,3
6/24/2024 18:36:07,vsrikrithika@gmail.com,Sri Krithika ,IPhD,First year,Yes,,1,
6/24/2024 18:47:24,saikatb.physics@gmail.com,Saikat Bera,PhD,First year,No,1,2,3
6/24/2024 18:57:56,aneshbishnoi0001@gmail.com,Anesh,PhD,First year,No,1,3,2
6/24/2024 19:37:26,abhinavdhawan147@gmail.com,Abhinav Dhawan ,PhD,First year,No,1,2,3
6/24/2024 19:49:54,gsaikat2022@gmail.com,Saikat Ghosh,PhD,First year,No,1,2,3
6/24/2024 20:32:17,sangeethas1729@gmail.com,Sangeetha S,PhD,First year,Yes,1,3,2
6/25/2024 8:00:16,elizabethsararoy@gmail.com,Elizabeth Sara Roy ,PhD,First year,Yes,1,2,3
6/30/2024 20:30:11,arupdatta1.618@gmail.com,ARUP DATTA,PhD,First year,No,1,2,3
6/26/2024 12:19:21,saibaayoub1@gmail.com,Saiba Ayoub ,IPhD,First year,Yes,1,3,2
6/26/2024 22:25:13,prajwaljadhav5183@gmail.com,Prajwal Prakashrao Jadhav ,PhD,First year,No,2,1,3
6/28/2024 5:44:39,bhatteranjali6@gmail.com,Anjali Bhatter,PhD,First year,Yes,1,3,2
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment