Skip to content
Snippets Groups Projects
Commit 4480c68b authored by Bruno Meyer's avatar Bruno Meyer :cry:
Browse files

Merge branch '138-3-reprovacoes-distintas' into 'development'

Resolve "3 reprovaçoes distintas" - CEPE

Closes #138

See merge request adega/adega!34
parents 1871c589 7bf47086
No related branches found
No related tags found
1 merge request!1WIP: Development
"""This resolution from CEPE deals with the cases where studants might have
their academic record canceled."""
import numpy as np
import pandas as pd
from script.utils.situations import *
def student_three_fails_subject(df):
df = df[df['SITUACAO'].isin(Situation.SITUATION_FAIL)]
df = df[(df['FORMA_EVASAO'] == EvasionForm.EF_ATIVO)]
students = df.groupby(["NOME_PESSOA", "MATR_ALUNO"])
names = {}
for student in students:
subjects = student[1].groupby("COD_ATIV_CURRIC")
for subject in subjects:
if subject[1].shape[0] >= 3:
names[student[0][0]] = student[0][1]
break
return names
"""This resolution from CEPE deals with the cases where studants might have
their academic record canceled."""
import numpy as np
import pandas as pd
import pprint
from script.utils.situations import *
fails_by_course = [10] # used at: student_three_fails_course
fails_by_semester = [6, 10] # used at: n_fails_semester
pp = pprint.PrettyPrinter(indent=4)
# for x in LISTA_DISCIPLINA_REPROVACOES_CONTAGEM:
# computa_lista_reprovacoes(reprovacoes=x)
def student_fails_course(df):
"""
Lists of students that failed X, Y, Z ... times in the same course.
X, Y, Z ... are declared in the list "fails_by_course" at the top of analysis.
This function is inspired by CEPE 96/15 ART.9:
Students with 3 fails in the same course would have their registration suspended.
Parameters
----------
df : DataFrame
Returns
-------
dict of {int:dict}
quantity={
"3":{aluno1:GRR, aluno2:GRR, ...},
"7":{aluno1:GRR, aluno2:GRR, ...},
...
}
Examples
--------
"3" : {
"José da Silva Carvalho": 20114027,
"Pedro dos Santos" : 20152678,
...
}
"7" : {
"José da Silva Carvalho": 20114027,
"Pedro dos Santos" : 20152678,
...
}
"""
# Filters based on the students that have failed at least once
# and are still registered on the University
df = df[df['SITUACAO'].isin(Situation.SITUATION_FAIL)]
df = df[(df['FORMA_EVASAO'] == EvasionForm.EF_ATIVO)]
# Creates a tuple with (specified informations, dataframe)
students = df.groupby(["NOME_PESSOA", "MATR_ALUNO"])
quantity = {}
for times in fails_by_course:
names = {}
for student in students:
# For each student that have failed, we will have a dataframe of
# the student and in wich course they did fail
courses = student[1].groupby("COD_ATIV_CURRIC")
for course in courses:
if course[1].shape[0] == times: #shape count the lines
names[student[0][0]] = student[0][1]
break
quantity[str(times)] = names
return quantity
def n_fails_semester (df):
"""
Lists of students that failed X, Y, Z ... courses in the same semester.
X, Y, Z ... are declared in the list "fails_by_semester" at the top.
This function is inspired by CEPE 96/15 ART.9:
Students with 3 fails in the semester would have their registration suspended.
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
----------
df : DataFrame
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')],
"""
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','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 = {}
student_grouped = semester[1].groupby(["NOME_PESSOA", "MATR_ALUNO"])
for student in student_grouped:
names_dict[student[0]] = student[1]
semester_dict[semester[0]] = names_dict
# 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:
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
......@@ -4,7 +4,7 @@ from script.analysis.degree_analysis import *
from script.analysis.student_analysis import *
from script.analysis.course_analysis import Course
from script.analysis.admission_analysis import *
from script.analysis.cepe9615 import *
from script.analysis.cepe9615_analysis import *
from collections import defaultdict
......@@ -27,6 +27,12 @@ def build_cache(dataframe,path):
generate_cepe_data(path+'/others/',df)
def generate_cepe_data(path,df):
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)
ensure_path_exists(path+'students')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment