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
c7430986
Commit
c7430986
authored
7 years ago
by
odair mario
Browse files
Options
Downloads
Patches
Plain Diff
json das taxas gerais e quantidades
parent
e0edafb7
No related branches found
No related tags found
1 merge request
!1
WIP: Development
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
script/analysis/course_analysis.py
+15
-9
15 additions, 9 deletions
script/analysis/course_analysis.py
script/base/dataframe_base.py
+4
-3
4 additions, 3 deletions
script/base/dataframe_base.py
script/main.py
+2
-2
2 additions, 2 deletions
script/main.py
with
21 additions
and
14 deletions
script/analysis/course_analysis.py
+
15
−
9
View file @
c7430986
...
@@ -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)
...
...
This diff is collapsed.
Click to expand it.
script/base/dataframe_base.py
+
4
−
3
View file @
c7430986
...
@@ -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
This diff is collapsed.
Click to expand it.
script/main.py
+
2
−
2
View file @
c7430986
...
@@ -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
))
...
...
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