Commit d3422031 authored by Odair M.'s avatar Odair M.

#179: fix course analysis

parent b7d4b610
Pipeline #19836 passed with stage
in 2 minutes and 54 seconds
......@@ -50,7 +50,7 @@ class Course(Analysis):
"SITUACAO",
[sit.SIT_CONHECIMENTO_APROVADO],
list(sit.SITUATION_KNOWLDGE),
1
2
),
rate(
"taxa_reprovacao_frequencia",
......@@ -69,7 +69,8 @@ class Course(Analysis):
__semestral_rate = [__rates[1]]
last_rate = [__rates[0], __rates[4]]
def __init__(self, df):
def __init__(self, current_year, df):
self.current_year = current_year
df_filted = df[df['SITUACAO'].isin(sit.SITUATION_COURSED)]
dict_df = {
"normal_dataframe": df,
......@@ -138,7 +139,7 @@ class Course(Analysis):
last_rates = self.last_rate
def f(x, rate):
x1 = x.loc[x.ANO == x.ANO.max()]
x1 = x.loc[x.ANO == x.ANO.max() - 1]
x_num = x1[x1[rate.collumn_name].isin(rate.fields_x)].shape[0]
x_deno = x1[x1[rate.collumn_name].isin(rate.fields_X)].shape[0]
return x_num / x_deno if x_deno > 0 else 0
......@@ -199,9 +200,9 @@ class Course(Analysis):
serie_mean = group.apply(lambda x: x["MEDIA_FINAL"].mean())
serie_std = group.apply(lambda x: x["MEDIA_FINAL"].std())
last_year_mean = group.apply(
lambda x: x.loc[x.ANO == x.ANO.max()].MEDIA_FINAL.mean())
lambda x: x.loc[x.ANO == x.ANO.max() - 1].MEDIA_FINAL.mean())
last_year_std = group.apply(
lambda x: x.loc[x.ANO == x.ANO.max()].MEDIA_FINAL.std())
lambda x: x.loc[x.ANO == x.ANO.max() - 1].MEDIA_FINAL.std())
# caso tenha algum nan, troque por 0.0
serie_mean[np.isnan(serie_mean)] = 0.0
serie_std[np.isnan(serie_std)] = 0.0
......
......@@ -195,8 +195,8 @@ class StudentAnalysis:
aux = df.groupby(["MATR_ALUNO", "ANO_INGRESSO", "SEMESTRE_INGRESSO"])
students = {}
for x in aux:
students[x[0][0]] = (CURRENT_YEAR - int(x[0][1])) * \
2 + CURRENT_SEMESTER - int(x[0][2]) + 1
students[x[0][0]] = (self.current_year - int(x[0][1])) * \
2 + self.current_semester - int(x[0][2]) + 1
return students
@memoize
......
......@@ -38,7 +38,7 @@ def build_cache(dataframe, path, current_year = CURRENT_YEAR, current_semester =
generate_degree_data(path, df, student_analysis)
generate_student_data(path + 'students/', df, student_analysis)
generate_admission_data(path + 'admissions/', df, student_analysis)
generate_course_data(path + 'courses/', dataframe)
generate_course_data(path + 'courses/',current_year, dataframe)
generate_cepe_data(path + '/others/', df)
......@@ -204,8 +204,8 @@ def generate_admission_list(path, df):
pass
def generate_course_data(path, df):
course = Course(df)
def generate_course_data(path, current_year, df):
course = Course(current_year,df)
course.build_analysis()
courses = course.build_general_course()
save_json(path + "disciplinas.json", courses)
......
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