student_analysis.py 3.37 KB
 Bruno Meyer committed Nov 10, 2017 1 ``````import numpy as np `````` Bruno Meyer committed Oct 01, 2017 2 `````` `````` 3 ``````from utils.situations import * `````` Bruno Meyer committed Oct 09, 2017 4 `````` `````` Bruno Meyer committed Oct 16, 2017 5 6 ``````ANO_ATUAL = 2017 SEMESTRE_ATUAL = 2 `````` Bruno Meyer committed Oct 09, 2017 7 `````` `````` 8 `````` `````` Bruno Meyer committed Nov 10, 2017 9 10 11 ``````def listagem_alunos_ativos(df): return list(df["MATR_ALUNO"][df["FORMA_EVASAO"] == EvasionForm.EF_ATIVO].drop_duplicates()) `````` 12 13 `````` `````` Bruno Meyer committed Oct 05, 2017 14 `````` `````` Bruno Meyer committed Oct 16, 2017 15 ``````def posicao_turmaIngresso_semestral(df): `````` Bruno Meyer committed Nov 10, 2017 16 17 18 19 20 21 22 23 24 25 26 27 28 29 `````` iras = ira_semestral(df) iraMax = {} for matr in iras: for semestreAno in iras[matr]: if not (semestreAno in iraMax): iraMax[semestreAno] = iras[matr][semestreAno] else: if (iras[matr][semestreAno] > iraMax[semestreAno]): iraMax[semestreAno] = iras[matr][semestreAno] for matr in iras: for semestreAno in iras[matr]: iras[matr][semestreAno] /= iraMax[semestreAno] return iras `````` 30 `````` `````` Bruno Meyer committed Oct 16, 2017 31 32 `````` def periodo_real(df): `````` Bruno Meyer committed Nov 10, 2017 33 34 35 36 37 `````` aux = df.groupby(["MATR_ALUNO"]) students = {} for x in aux: students[x[0]] = None return students `````` 38 `````` `````` Bruno Meyer committed Oct 16, 2017 39 `````` `````` Bruno Meyer committed Oct 09, 2017 40 ``````def periodo_pretendido(df): `````` Bruno Meyer committed Nov 10, 2017 41 42 43 44 45 `````` aux = df.groupby(["MATR_ALUNO", "ANO_INGRESSO", "SEMESTRE_INGRESSO"]) students = {} for x in aux: students[x[0][0]] = (ANO_ATUAL - int(x[0][1])) * 2 + SEMESTRE_ATUAL - int(x[0][2]) + 1 return students `````` 46 `````` `````` Bruno Meyer committed Oct 09, 2017 47 `````` `````` Bruno Meyer committed Nov 10, 2017 48 49 50 51 52 53 ``````def ira_semestral(df): aux = ira_por_quantidade_disciplinas(df) for matr in aux: for periodo in aux[matr]: aux[matr][periodo] = aux[matr][periodo][0] return aux `````` 54 `````` `````` Bruno Meyer committed Oct 01, 2017 55 `````` `````` Bruno Meyer committed Oct 04, 2017 56 ``````def ira_por_quantidade_disciplinas(df): `````` Bruno Meyer committed Nov 10, 2017 57 58 59 60 61 `````` students = {} df = df.dropna(subset=["MEDIA_FINAL"]) total_students = len(df["MATR_ALUNO"]) for i in range(total_students): `````` Bruno Meyer committed Jan 25, 2018 62 `````` matr = df["MATR_ALUNO"][i] `````` Bruno Meyer committed Nov 10, 2017 63 64 65 66 67 68 69 `````` if (not (matr in students)): students[matr] = {} ano = str(int(df["ANO"][i])) semestre = str(df["PERIODO"][i]) situacao = int(df["SITUACAO"][i]) nota = float(df["MEDIA_FINAL"][i]) `````` Bruno Meyer committed Jan 25, 2018 70 `````` carga = float(df["CH_TOTAL"][i]) `````` Bruno Meyer committed Nov 10, 2017 71 `````` media_credito = int(df["MEDIA_CREDITO"][i]) `````` Bruno Meyer committed Jan 25, 2018 72 73 `````` `````` Bruno Meyer committed Nov 10, 2017 74 75 `````` if (situacao in Situation.SITUATION_AFFECT_IRA and media_credito != 0): if not (ano + "/" + semestre in students[matr]): `````` Bruno Meyer committed Jan 25, 2018 76 77 78 `````` students[matr][ano + "/" + semestre] = [0, 0, 0] students[matr][ano + "/" + semestre][0] += nota*carga `````` Bruno Meyer committed Nov 10, 2017 79 `````` students[matr][ano + "/" + semestre][1] += 1 `````` Bruno Meyer committed Jan 25, 2018 80 `````` students[matr][ano + "/" + semestre][2] += carga `````` Bruno Meyer committed Nov 10, 2017 81 82 83 `````` for matr in students: for periodo in students[matr]: `````` Bruno Meyer committed Jan 25, 2018 84 85 `````` if (students[matr][periodo][2] != 0): students[matr][periodo][0] /= students[matr][periodo][2] * 100 `````` Bruno Meyer committed Nov 10, 2017 86 `````` return (students) `````` 87 `````` `````` Bruno Meyer committed Oct 04, 2017 88 `````` `````` Bruno Meyer committed Oct 04, 2017 89 ``````def indice_aprovacao_semestral(df): `````` Bruno Meyer committed Nov 10, 2017 90 91 92 93 94 95 96 `````` 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] = {} `````` 97 `````` `````` Bruno Meyer committed Nov 10, 2017 98 99 100 `````` ano = str(int(df["ANO"][i])) semestre = str(df["PERIODO"][i]) situacao = int(df["SITUACAO"][i]) `````` 101 `````` `````` Bruno Meyer committed Nov 10, 2017 102 103 `````` if not (ano + "/" + semestre in students[matr]): students[matr][ano + "/" + semestre] = [0, 0] `````` 104 `````` `````` Bruno Meyer committed Nov 10, 2017 105 106 107 108 109 110 `````` if situacao in Situation.SITUATION_PASS: students[matr][ano + "/" + semestre][0] += 1 students[matr][ano + "/" + semestre][1] += 1 if situacao in Situation.SITUATION_FAIL: students[matr][ano + "/" + semestre][1] += 1 return (students) `````` 111 `````` `````` Bruno Meyer committed Oct 04, 2017 112 `````` `````` Bruno Meyer committed Oct 01, 2017 113 ``````def aluno_turmas(df): `````` Bruno Meyer committed Nov 10, 2017 114 115 `````` students = {} df = df.dropna(subset=['MEDIA_FINAL']) `````` 116 `````` `````` Bruno Meyer committed Nov 10, 2017 117 `````` situations = dict(Situation.SITUATIONS) `````` 118 `````` `````` Bruno Meyer committed Nov 10, 2017 119 120 `````` for matr, hist in df.groupby('MATR_ALUNO'): students[matr] = [] `````` 121 `````` `````` Bruno Meyer committed Nov 10, 2017 122 123 124 125 126 127 128 129 130 `````` for _, row in hist.iterrows(): data = { 'ano': str(int(row["ANO"])), 'codigo': row["COD_ATIV_CURRIC"], 'nome': row["NOME_ATIV_CURRIC"], 'nota': row["MEDIA_FINAL"], 'semestre': row["PERIODO"], 'situacao': situations.get(row["SITUACAO"], Situation.SIT_OUTROS) } `````` 131 `````` `````` Bruno Meyer committed Nov 10, 2017 132 `````` students[matr].append(data) `````` 133 `````` `````` Bruno Meyer committed Nov 10, 2017 134 `` return students``