Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
adega
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Odair M.
adega
Commits
d66276ab
Commit
d66276ab
authored
6 years ago
by
maria ruy
Browse files
Options
Downloads
Patches
Plain Diff
adega#47: Add admission_class_ira_per_semester function on admission_analysis.py
parent
ed6cb8b4
No related branches found
No related tags found
1 merge request
!1
WIP: Development
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/script/analysis/admission_analysis.py
+53
-0
53 additions, 0 deletions
src/script/analysis/admission_analysis.py
src/script/build_cache.py
+28
-21
28 additions, 21 deletions
src/script/build_cache.py
with
81 additions
and
21 deletions
src/script/analysis/admission_analysis.py
+
53
−
0
View file @
d66276ab
...
...
@@ -9,6 +9,59 @@ import numpy as np
ANO_ATUAL
=
2017
SEMESTRE_ATUAL
=
2
def
admission_class_ira_per_semester
(
df
):
"""
Calculate the average IRA in every semester of the admission classes.
This function group the dataframe by admission classes.
Then group each class by semesters.
And finally group each semester by student.
Calculate each student
'
s IRA and then the average IRA for the class.
Parameters
----------
df : DataFrame
Returns
-------
dict of {list:dict}
dict_admission={
(admission_class1):{semester1:ira, semester2:ira, ...},
(admission_class2):{semester1:ira, semester2:ira, ...},
...
}
Examples
--------
{(
'
2005
'
,
'
1
'
): {(2012,
'
1o. Semestre
'
): 0.485,
(2007,
'
1o. Semestre
'
): 0.6186531973412296, ...} ...}
"""
df
=
df
[
df
[
'
SITUACAO
'
].
isin
(
Situation
.
SITUATION_AFFECT_IRA
)]
df
=
df
[
df
[
'
TOTAL_CARGA_HORARIA
'
]
!=
0
]
admission_grouped
=
df
.
groupby
([
'
ANO_INGRESSO_y
'
,
'
SEMESTRE_INGRESSO
'
])
dict_admission
=
{}
for
admission
in
admission_grouped
:
#admission_grouped is a tuple of tuples, each tuple contains 0-tuple year/semester & 1-dataframe
dict_ira_semester
=
{}
semester_grouped
=
admission
[
1
].
groupby
([
'
ANO
'
,
'
PERIODO
'
])
for
semester
in
semester_grouped
:
student_grouped
=
semester
[
1
].
groupby
(
'
ID_ALUNO
'
)
ira_class
=
0
for
student
in
student_grouped
:
#TODO: Verify if this can be calculated without groupby
ira_individual
=
(
(
student
[
1
].
MEDIA_FINAL
*
student
[
1
].
TOTAL_CARGA_HORARIA
).
sum
()
)
/
(
100
*
student
[
1
].
TOTAL_CARGA_HORARIA
.
sum
())
ira_class
+=
ira_individual
ira_class
=
ira_class
/
len
(
student_grouped
)
dict_ira_semester
.
update
({
semester
[
0
]:
ira_class
})
dict_admission
.
update
({
admission
[
0
]:
dict_ira_semester
})
return
dict_admission
def
iras_alunos_turmas_ingressos
(
df
):
iras
=
ira_alunos
(
df
)
...
...
This diff is collapsed.
Click to expand it.
src/script/build_cache.py
+
28
−
21
View file @
d66276ab
...
...
@@ -21,7 +21,7 @@ def build_cache(dataframe,path):
path
=
path
+
'
/
'
generate_degree_data
(
path
,
df
)
generate_student_data
(
path
+
'
students/
'
,
df
)
generate_admission_data
(
path
+
'
/
admission/
'
,
df
)
generate_admission_data
(
path
+
'
admission/
'
,
df
)
generate_course_data
(
path
+
'
disciplina/
'
,
dataframe
)
def
generate_degree_data
(
path
,
dataframe
):
...
...
@@ -121,33 +121,38 @@ def generate_student_list(path):
def
generate_admission_data
(
path
,
df
):
listagem
=
[]
listagem
=
[]
analises
=
[
(
"
ira
"
,
media_ira_turma_ingresso
(
df
)),
(
"
desvio_padrao
"
,
desvio_padrao_turma_ingresso
(
df
)),
]
analises
=
[
(
"
ira
"
,
media_ira_turma_ingresso
(
df
)),
(
"
std
"
,
desvio_padrao_turma_ingresso
(
df
)),
(
"
ira_per_semester
"
,
admission_class_ira_per_semester
(
df
)),
]
# cria um dicionario com as analises para cada turma
turmas
=
defaultdict
(
dict
)
for
a
in
analises
:
for
x
in
a
[
1
]:
turmas
[
x
][
a
[
0
]
]
=
a
[
1
][
x
]
# cria um dicionario com as analises para cada turma
turmas
=
defaultdict
(
dict
)
for
a
in
analises
:
for
x
in
a
[
1
]:
valor
=
a
[
1
][
x
]
x
=
(
str
(
x
[
0
]),
str
(
x
[
1
]))
turmas
[
x
][
a
[
0
]
]
=
valor
listagem
=
[]
listagem
=
[]
for
t
in
turmas
:
resumo_turma
=
{
"
ano
"
:
x
[
0
],
"
semestre
"
:
x
[
1
]
}
for
t
in
turmas
:
resumo_turma
=
{
"
ano
"
:
t
[
0
],
"
semestre
"
:
t
[
1
]
}
for
analise
in
turmas
[
t
]:
resumo_turma
[
analise
]
=
turmas
[
t
][
analise
]
listagem
.
append
(
resumo_turma
)
for
analise
in
turmas
[
t
]:
resumo_turma
[
analise
]
=
turmas
[
t
][
analise
]
listagem
.
append
(
resumo_turma
)
save_json
(
path
+
"
lista_turma_ingresso.json
"
,
listagem
)
save_json
(
path
+
"
lista_turma_ingresso.json
"
,
listagem
)
def
generate_admission_list
(
path
,
df
):
...
...
@@ -164,3 +169,5 @@ def generate_course_data(path,df):
disciplinas
=
listagem_disciplina
(
df
,
lista_disciplinas
)
save_json
(
path
+
'
disciplinas.json
'
,
disciplinas
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment