Commit 3fe3fbde authored by msrr18's avatar msrr18 😑
Browse files

#138: terminei =)

parent 0a0db6e0
Pipeline #17903 passed with stage
in 12 seconds
......@@ -7,7 +7,7 @@ from script.utils.situations import *
fails_by_course = [10] # used at: student_three_fails_course
fails_by_semester = [1, 3] # used at: n_fails_semester
fails_by_semester = [6, 10] # used at: n_fails_semester
pp = pprint.PrettyPrinter(indent=4)
......@@ -84,18 +84,11 @@ def n_fails_semester (df):
This function is inspired by CEPE 96/15 ART.9:
Students with 3 fails in the semester would have their registration suspended.
ESBOÇO:
PEGAR OS alunos em SITUATION_FAIL --feito
daí agrupar em semestres
Para cada n em fails_by_semester:
agrupar por alunos
contar quantos linhas, se maior que N
gera dicionario com N itens, um para cada item em fails_by_semester
N: outro_dict
outro_dict tem como chave SEMESTRE: (lista de nomes)
First this function filters students who are still registrered in the University
and have failed courses.
Then it creates a dictionary of semesters.
Inside each semester there is a second dictionary of names and df with the failed courses
This second dictionary will be turned into a list of names according to each N in fails_by_semester
Parameters
----------
......@@ -103,19 +96,34 @@ def n_fails_semester (df):
Returns
-------
dict of {int:dict}
final_dict={
"X":{semester1: list_of_students1, ...},
"Y":{semester1: list_of_students1, ...},
...
}
Examples
--------
'4': { (2001, '2o. Semestre'): [],
(2002, '1o. Semestre'): [],
(2002, '2o. Semestre'): [],
(2003, '1o. Semestre'): [],
(2004, '2o. Semestre'): [],
(2007, '1o. Semestre'): [],
(2007, '2o. Semestre'): [ ( 'Carlos das Neves Vieira',
'GRR20073713'),
( 'Adriano Dias Barbosa',
'GRR20075214')],
(2008, '1o. Semestre'): [ ( 'Anderson Silveira Alves',
'GRR20075297')],
"""
# N = fails_by_semester;
people_studying_df = df[df['FORMA_EVASAO'] == EvasionForm.EF_ATIVO]
failed_people_df = people_studying_df[people_studying_df['SITUACAO'].isin(Situation.SITUATION_FAIL)]
failed_people_per_semester_grouped = failed_people_df.groupby(['ANO_INGRESSO_y','SEMESTRE_INGRESSO'])
# semester_dict - semesters: names_dict
# names_dict - names : df with courses failed by that student in that semester
# names_dict will be turned into a list of names according to each N in fails_by_semester
failed_people_per_semester_grouped = failed_people_df.groupby(['ANO','PERIODO'])
# semester_dict = { (2017/1): names_dict1, (2017/2): names_dict2, ...}
# names_dict = { (nome, grr): df, (nome. grr): df, ...)
semester_dict = {}
for semester in failed_people_per_semester_grouped:
names_dict = {}
......@@ -124,17 +132,18 @@ def n_fails_semester (df):
names_dict[student[0]] = student[1]
semester_dict[semester[0]] = names_dict
# final_dict - N: semester_dict
# semester_dict - semester: names of students tha failed N courses in that semester
# final_dict = { N: semester_finaldict, ...}
# semester_finaldict = { semester: list of students tha failed N courses in that semester}
final_dict = {}
# for n in fails_by_semester:
for semester in semester_dict:
name_list = []
for student in semester_dict[semester]:
if semester_dict[semester][student].shape[0] == 10:
name_list.append(student)
semester_dict[semester] = name_list
final_dict[str(3)] = semester_dict
pp.pprint (final_dict)
for n in fails_by_semester:
semester_finaldict = {}
for semester in semester_dict:
name_list = []
for student in semester_dict[semester]:
if semester_dict[semester][student].shape[0] == n:
name_list.append(student)
semester_finaldict[semester] = name_list
final_dict[str(n)] = semester_finaldict
# pp.pprint (final_dict)
return final_dict
......@@ -28,10 +28,10 @@ def build_cache(dataframe,path):
def generate_cepe_data(path,df):
# name_dict = student_fails_course(df)
# save_json(path+"cepe9615.json", name_dict)
name_dict = n_fails_semester(df)
save_json(path+"cepe9615.json", name_dict)
cepe_dict = {}
cepe_dict["student_fails_course"] = student_fails_course(df)
cepe_dict["n_fails_semester"] = n_fails_semester(df)
save_json(path+"cepe9615.json", cepe_dict)
def generate_degree_data(path, dataframe):
ensure_path_exists(path)
......
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 to comment