Skip to content
Snippets Groups Projects
Commit c7430986 authored by odair mario's avatar odair mario
Browse files

json das taxas gerais e quantidades

parent e0edafb7
No related branches found
No related tags found
1 merge request!1WIP: Development
...@@ -3,6 +3,8 @@ import pandas as pd ...@@ -3,6 +3,8 @@ import pandas as pd
import json import json
import numpy as np import numpy as np
import utils.situations import utils.situations
from collections import OrderedDict, defaultdict
# df = pd.read_excel("../base/base-2016-1/historico.xls") # df = pd.read_excel("../base/base-2016-1/historico.xls")
# imprime completamente um dataframe # imprime completamente um dataframe
...@@ -17,7 +19,7 @@ def print_analise(d): ...@@ -17,7 +19,7 @@ def print_analise(d):
def func(x, matr): def func(x, matr):
c = matr[x['COD_ATIV_CURRIC']].values[0] c = matr[x['COD_ATIV_CURRIC']].values[0]
return (x['counts'] / c) return (x['Quantidade'] / c)
# quantidade de matriculas # quantidade de matriculas
...@@ -30,15 +32,18 @@ def analysis(df): ...@@ -30,15 +32,18 @@ def analysis(df):
qnt_matr = counts_matr(df) # quantidade de matriculas disciplina qnt_matr = counts_matr(df) # quantidade de matriculas disciplina
# conta quantas vezes os valores de 'SIGLA' se repete para cada disciplina # conta quantas vezes os valores de 'SIGLA' se repete para cada disciplina
disciplinas = df.groupby(['COD_ATIV_CURRIC', 'SIGLA'] disciplinas = df.groupby(['COD_ATIV_CURRIC', 'SIGLA']
).size().reset_index(name='counts') ).size().reset_index(name='Quantidade')
# adiciona mais uma coluna ao df disciplina com as taxas de cada valor de 'SIGLA' # adiciona mais uma coluna ao df disciplina com as taxas de cada valor de 'SIGLA'
disciplina = disciplinas.groupby(['COD_ATIV_CURRIC', 'SIGLA', 'counts']).apply( disciplina = disciplinas.groupby(['COD_ATIV_CURRIC', 'SIGLA', 'Quantidade']).apply(
lambda x: func(x, qnt_matr)).reset_index(name='taxas gerais') lambda x: func(x, qnt_matr)).reset_index(name='Taxas gerais')
# print(disciplina) disciplina = disciplina.drop('level_3',1)
return disciplina for dis in qnt_matr.keys():
disc = disciplina.loc[disciplina['COD_ATIV_CURRIC']==dis].drop('COD_ATIV_CURRIC',1)
disc = disc.set_index('SIGLA').to_dict(into=OrderedDict)
with open(dis+'.json','w') as f:
json.dump(disc,f,indent=4)
return disciplina.set_index('COD_ATIV_CURRIC')
# quantidade de vezes cursadas ate obter a aprovacao # quantidade de vezes cursadas ate obter a aprovacao
def qnt_aprov(df): def qnt_aprov(df):
qnt = df.groupby(['MATR_ALUNO', 'COD_ATIV_CURRIC'] qnt = df.groupby(['MATR_ALUNO', 'COD_ATIV_CURRIC']
).size().reset_index(name='qnt_aprov') ).size().reset_index(name='qnt_aprov')
...@@ -77,9 +82,10 @@ def analysis_semestre(df): ...@@ -77,9 +82,10 @@ def analysis_semestre(df):
def Main(df): def Main(df):
Analysis = analysis(df) Analysis = analysis(df)
Analysis_semestre = analysis_semestre(df) Analysis_semestre = analysis_semestre(df)
# print_analise(Analysis)
matr = counts_matr(df) matr = counts_matr(df)
matr_semes = matr_semestre(df) matr_semes = matr_semestre(df)
print_analise(merged) # print_analise(merged)
# main() # main()
# matr = counts_matr(df) # matr = counts_matr(df)
......
...@@ -10,7 +10,7 @@ from utils.situations import * ...@@ -10,7 +10,7 @@ from utils.situations import *
def load_dataframes(cwd='.'): def load_dataframes(cwd='.'):
dataframes = [] dataframes = []
for path, dirs, files in os.walk(cwd): for path, dirs, files in os.walk(cwd):
for f in files: for f in files:
file_path = path + '/' + f file_path = path + '/' + f
dh = {'name': f, 'dataframe': None} dh = {'name': f, 'dataframe': None}
...@@ -84,5 +84,6 @@ def fix_admission(df): ...@@ -84,5 +84,6 @@ def fix_admission(df):
def fix_evasion(df): def fix_evasion(df):
for evasion in EvasionForm.EVASION_FORM: # for evasion in EvasionForm.EVASION_FORM:
df.loc[df.FORMA_EVASAO.str.contains(evasion[1]).fillna(False), 'FORMA_EVASAO'] = evasion[0] # df.loc[df.FORMA_EVASAO.str.contains(evasion[1]).fillna(False), 'FORMA_EVASAO'] = evasion[0]
pass
...@@ -4,7 +4,7 @@ from base.dataframe_base import load_dataframes ...@@ -4,7 +4,7 @@ from base.dataframe_base import load_dataframes
from build_cache import build_cache from build_cache import build_cache
from datetime import timedelta from datetime import timedelta
from utils.situations import * from utils.situations import *
from analysis.course_analysis import *
def main(): def main():
start_time = time.clock() start_time = time.clock()
start_time_exec = time.time() start_time_exec = time.time()
...@@ -12,7 +12,7 @@ def main(): ...@@ -12,7 +12,7 @@ def main():
dataframe = load_dataframes(os.getcwd() + '/' + 'base') dataframe = load_dataframes(os.getcwd() + '/' + 'base')
build_cache(dataframe) build_cache(dataframe)
Main(dataframe)
cpu_time = timedelta(seconds=round(time.clock() - start_time)) cpu_time = timedelta(seconds=round(time.clock() - start_time))
run_time = timedelta(seconds=round(time.time() - start_time_exec)) run_time = timedelta(seconds=round(time.time() - start_time_exec))
print("--- Tempo de CPU: {} ---".format(cpu_time)) print("--- Tempo de CPU: {} ---".format(cpu_time))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment