Commit 2edb4f14 authored by Bruno Meyer's avatar Bruno Meyer 😢

Merge branch '137-3-reprovacoes-em-2-distintas' into 'development'

#137 3 reprovacoes em 2 disciplinas distintas

Closes #137

See merge request adega/adega!59
parents 7b4fd819 5d164c46
......@@ -76,6 +76,72 @@ def student_fails_course(df):
return quantity
def student_fails_2_courses(df):
"""
Lists of students that failed X, Y, Z ... times in the 2 different courses.
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 two different courses 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,
...
}
"""
most_failures = 0
second_most_failures = 0
# 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 which course they did fail
courses = student[1].groupby("COD_ATIV_CURRIC")
for course in courses:
if course[1].shape[0] > most_failures:
most_failures = course[1].shape[0]
elif course[1].shape[0] > second_most_failures:
second_most_failures = course[1].shape[0]
if (most_failures != 0) and (second_most_failures != 0):
if (most_failures + second_most_failures) >= times:
names[student[0][0]] = student[0][1]
break
quantity[str(times)] = names
return quantity
def fails_semester (df):
"""
......
......@@ -43,6 +43,7 @@ def build_cache(dataframe, path):
def generate_cepe_data(path, df):
cepe_dict = {}
cepe_dict["student_fails_course"] = student_fails_course(df)
cepe_dict["student_fails_2_courses"] = student_fails_2_courses(df)
cepe_dict["fails_semester"] = fails_semester(df)
cepe_dict["fails_by_freq_semester"] = fails_by_freq_semester(df)
cepe_dict["fails_by_freq"] = fails_by_freq(df)
......
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