CoCalc Shared FilesTA Sandbox / Sep / Roster / Learning-groups-2I.sagews
Views : 12
Description: Script to randomly assign students to learning teams
# input parameters

group_size = 4
csv_file = 'Roster-2I.csv' #download roster from MyUCLA as .csv -- delete first 8 lines before columns of table


# import packages
from sage.misc.prandom import shuffle
import pandas as p



roster.columns = ['UID','Name','Email','Major','Classification','Grade Type','Status','Section']
names = roster['Name']
names

0 AHN, ESTHER (SUHYOUNG) 1 ARZATE, DANIELA 2 HILL, KALAYA ELIZABETH 3 HONG, SANG HYOUN 4 JUUL, LAUREN LISETTE 5 KIESSLING, SOPHIA B 6 KUBARI, KANI SABIT 7 LEE, MHUN-JEONG ISAAC 8 LUJANO, YAMILETTE DE LA CARIDAD 9 NARVAEZ, JENNIFER N 10 NAVARRETE, JENNIFER 11 OJEIKERE, TAIYE BRITTANY 12 OLMEDA, BELINDA BRIANNA 13 RAMOS, SALVADOR 14 RIVAS, CYNTHIA N 15 SAWAYA, JESSICA RAMZY 16 SCHWESINGER, PAYTON JANE 17 TAK, KRITIKA 18 TRUJILLO, MARIA ISABEL 19 VILLEDA, LILIANA RACQUEL Name: Name, dtype: object


names_list = names.values.tolist()
class_size = len(names_list)
n_groups = ceil(class_size/group_size)
shuffle(names_list)

for i in range(n_groups):
start = group_size*i
if i == n_groups-1:
end = class_size
else:
end = start + group_size
print([ names_list[j] for j in range(start,end) ])

['LEE, MHUN-JEONG ISAAC', 'TAK, KRITIKA', 'RAMOS, SALVADOR', 'SCHWESINGER, PAYTON JANE'] ['LUJANO, YAMILETTE DE LA CARIDAD', 'OJEIKERE, TAIYE BRITTANY', 'RIVAS, CYNTHIA N', 'KUBARI, KANI SABIT'] ['SAWAYA, JESSICA RAMZY', 'OLMEDA, BELINDA BRIANNA', 'NAVARRETE, JENNIFER', 'AHN, ESTHER (SUHYOUNG)'] ['HONG, SANG HYOUN', 'ARZATE, DANIELA', 'NARVAEZ, JENNIFER N', 'HILL, KALAYA ELIZABETH'] ['VILLEDA, LILIANA RACQUEL', 'KIESSLING, SOPHIA B', 'JUUL, LAUREN LISETTE', 'TRUJILLO, MARIA ISABEL']