From 60baa6492dcdec0b9944892cc6a2cbcb725896e9 Mon Sep 17 00:00:00 2001
From: Bruno Meyer <buba.meyer_@hotmail.com>
Date: Wed, 4 Oct 2017 16:07:59 -0300
Subject: [PATCH] ira_por_quantidade_disciplinas

---
 script/analysis/student_analysis.py | 30 +++++++++++++++++++++++++++++
 script/build_cache.py               |  3 ++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/script/analysis/student_analysis.py b/script/analysis/student_analysis.py
index d26d48d..7397e78 100644
--- a/script/analysis/student_analysis.py
+++ b/script/analysis/student_analysis.py
@@ -10,6 +10,36 @@ def average_ira(d):
         ch_total = np.sum(temp['CH_TOTAL']) * 100
         print(aux/ch_total)
 
+def ira_por_quantidade_disciplinas(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] = {}
+		
+		
+		ano = str(df["ANO"][i])
+		semestre = str(df["PERIODO"][i])
+		situacao = int(df["SITUACAO"][i])
+		nota = float(df["MEDIA_FINAL"][i])
+		
+		
+		
+		
+		if(situacao in Situation.SITUATION_AFFECT_IRA):
+			if not(ano+"/"+semestre in students[matr]):
+				students[matr][ano+"/"+semestre] = [0,0]
+			students[matr][ano+"/"+semestre][0]+=nota
+			students[matr][ano+"/"+semestre][1]+=1
+	
+	for matr in students:
+		for periodo in students[matr]:
+			if(students[matr][periodo][1] != 0):
+				students[matr][periodo][0]/=students[matr][periodo][1]*100
+	print(students)
+
 def indice_aprovacao_semestral(df):
 	students = {}
 	df = df.dropna(subset=['MEDIA_FINAL'])
diff --git a/script/build_cache.py b/script/build_cache.py
index af57d36..0ffd170 100644
--- a/script/build_cache.py
+++ b/script/build_cache.py
@@ -38,7 +38,8 @@ def generate_degree_data(path, dataframe):
 
 def generate_student_data(path,dataframe):
     #~ aluno_turmas(dataframe)
-    indice_aprovacao_semestral(dataframe)
+    #~ indice_aprovacao_semestral(dataframe)
+    ira_por_quantidade_disciplinas(dataframe)
     pass
 
 def generate_student_list(path):
-- 
GitLab