From e1bbb12fbdcaa5c108ca6e6fe3c2cf2c4b604f37 Mon Sep 17 00:00:00 2001 From: Bruno Meyer <buba.meyer_@hotmail.com> Date: Sun, 1 Oct 2017 15:14:13 -0300 Subject: [PATCH] aluno_turmas --- script/analysis/student_analysis.py | 63 +++++++++++++++++++++++++++++ script/base/dataframe_base.py | 11 +---- script/build_cache.py | 6 ++- 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/script/analysis/student_analysis.py b/script/analysis/student_analysis.py index e69de29..326e5bc 100644 --- a/script/analysis/student_analysis.py +++ b/script/analysis/student_analysis.py @@ -0,0 +1,63 @@ +import pandas as pd +from utils.situations import * + +def average_ira(d): + temp = d.dropna(subset=['MEDIA_FINAL']) + temp = temp[temp['MEDIA_FINAL'] <= 100] + if not temp.empty: + #print(temp[['MEDIA_FINAL', 'CH_TOTAL']]) + aux = np.sum(temp['MEDIA_FINAL']*temp['CH_TOTAL']) + ch_total = np.sum(temp['CH_TOTAL']) * 100 + print(aux/ch_total) + +def aluno_turmas(df): + students = {} + df = df.dropna(subset=['MEDIA_FINAL']) + total_students = len(df["MATR_ALUNO"]) + for i in range(total_students): + matr = (df["MATR_ALUNO"][i]) + if(not (matr in students)): + students[matr] = [] + + for s in Situation.SITUATIONS: + if(s[0] == df["SITUACAO"][i]): + situacao = s[1] + break + ano = (df["ANO"][i]) + codigo = (df["COD_ATIV_CURRIC"][i]) + nome = (df["NOME_ATIV_CURRIC"][i]) + nota = (df["MEDIA_FINAL"][i]) + semestre = (df["PERIODO"][i]) + + students[matr].append({ + "ano": ano, + "codigo": codigo, + "nome": nome, + "nota": nota, + "semestre": semestre, + "situacao": situacao + }) + print(students) + #~ lines = (df[["MATR_ALUNO","ANO","COD_ATIV_CURRIC","NOME_ATIV_CURRIC","MEDIA_FINAL","PERIODO","SITUACAO"]]) + #~ for st in (df.groupby("MATR_ALUNO")): + #~ print(st[1]["MATR_ALUNO"]) + #~ print(st[1]["ANO"]) + #~ print(st[1]["COD_ATIV_CURRIC"]) + #~ print(st[1]["NOME_ATIV_CURRIC"]) + #~ print(st[1]["MEDIA_FINAL"]) + #~ print(st[1]["PERIODO"]) + #~ print(st[1]["SITUACAO"]) + #~ print("") + #~ total_student = df['MATR_ALUNO'].drop_duplicates() + #~ for st in total_student: + #~ students[st] = [] + #~ hist = df[df["MATR_ALUNO"]==st] + #~ for matr in hist: + #~ print(hist["ANO"]) + #~ print(hist[matr]["COD_ATIV_CURRIC"]) + #~ print(hist[matr]["NOME_ATIV_CURRIC"]) + #~ print(hist[matr]["MEDIA_FINAL"]) + #~ print(hist[matr]["PERIODO"]) + #~ print(hist[matr]["SITUACAO"]) + #~ print(hist[matr]) + #~ print("") diff --git a/script/base/dataframe_base.py b/script/base/dataframe_base.py index e831819..39c056f 100644 --- a/script/base/dataframe_base.py +++ b/script/base/dataframe_base.py @@ -8,15 +8,6 @@ from json import load as json_load from utils.situations import * -def teste(d): - temp = d.dropna(subset=['MEDIA_FINAL']) - temp = temp[temp['MEDIA_FINAL'] <= 100] - if not temp.empty: - #print(temp[['MEDIA_FINAL', 'CH_TOTAL']]) - aux = np.sum(temp['MEDIA_FINAL']*temp['CH_TOTAL']) - ch_total = np.sum(temp['CH_TOTAL']) * 100 - print(aux/ch_total) - class DataframeHolder: def __init__(self, dataframe): self.students = dataframe.groupby('MATR_ALUNO') @@ -111,4 +102,4 @@ def fix_evasion(df): #~ if(x != 0.0): #~ print(x) #~ print(df.FORMA_EVASAO.str.contains(evasion[1]).fillna(5)) - print(df[['MATR_ALUNO','FORMA_EVASAO']]) + #~ print(df[['MATR_ALUNO','FORMA_EVASAO']]) diff --git a/script/build_cache.py b/script/build_cache.py index 50ef82d..4f35839 100644 --- a/script/build_cache.py +++ b/script/build_cache.py @@ -7,6 +7,7 @@ from datetime import timedelta from pathlib import Path from utils.utils import build_path from analysis.degree_analysis import * +from analysis.student_analysis import * try: to_unicode = unicode @@ -22,7 +23,7 @@ def build_cache(dataframe): build_path(path) # generate_degree_data(path, dataframe) -# generate_student_data(path) + generate_student_data(path,dataframe) # generate_student_list(path) # generate_admission_data(path) # generate_admission_list(path) @@ -35,7 +36,8 @@ def generate_degree_data(path, dataframe): general_ira(dataframe) pass -def generate_student_data(path): +def generate_student_data(path,dataframe): + aluno_turmas(dataframe) pass def generate_student_list(path): -- GitLab