Spaces:
Sleeping
Sleeping
Strauss Cunha Carvalho commited on
Commit ·
58e48ed
1
Parent(s): 98e1408
dev:sqlite
Browse files
app.py
CHANGED
|
@@ -3,28 +3,67 @@ import sqlite3
|
|
| 3 |
import pandas as pd
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
pro_edp = 'https://huggingface.co/datasets/strauss-oak/afa-bd/raw/main/tb-professors.csv'
|
| 8 |
sch_edp = 'https://huggingface.co/datasets/strauss-oak/afa-bd/resolve/main/drw-inep.csv'
|
| 9 |
std_edp = 'https://huggingface.co/datasets/strauss-oak/afa-bd/resolve/main/tb-students.csv'
|
| 10 |
|
| 11 |
-
|
| 12 |
-
df_pro.to_sql("tb_professors", conn, if_exists="replace")
|
| 13 |
-
del df_pro
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
## Label Metrics Size
|
| 7 |
+
st.markdown("""<style>[data-testid="stMetricValue"] {font-size: 20px;}</style>""", unsafe_allow_html=True,)
|
| 8 |
+
|
| 9 |
+
## Horizontal Radio Button
|
| 10 |
+
st.write('<style>div.row-widget.stRadio > div{flex-direction:row;justify-content: left;} </style>', unsafe_allow_html=True)
|
| 11 |
+
|
| 12 |
+
#st.set_page_config(page_title="The Ramsey Highlights", layout="wide")
|
| 13 |
+
st.markdown("""<style>[data-testid="stSidebar"][aria-expanded="true"] > div:first-child{width: 370px;}
|
| 14 |
+
[data-testid="stSidebar"][aria-expanded="false"] > div:first-child{width: 370px;margin-left: -370px;}""",
|
| 15 |
+
unsafe_allow_html=True,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
pro_edp = 'https://huggingface.co/datasets/strauss-oak/afa-bd/raw/main/tb-professors.csv'
|
| 19 |
sch_edp = 'https://huggingface.co/datasets/strauss-oak/afa-bd/resolve/main/drw-inep.csv'
|
| 20 |
std_edp = 'https://huggingface.co/datasets/strauss-oak/afa-bd/resolve/main/tb-students.csv'
|
| 21 |
|
| 22 |
+
conn = sqlite3.connect("afa-db.db")
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
@st.cache_resource
|
| 25 |
+
def refresh_data_professors(conn):
|
| 26 |
+
df_pro = pd.read_csv(pro_edp)
|
| 27 |
+
df_pro.to_sql("tb_professors", conn, if_exists="replace")
|
| 28 |
+
df_pro = df_pro[:10]
|
| 29 |
+
return df_pro
|
| 30 |
|
| 31 |
+
@st.cache_resource
|
| 32 |
+
def refresh_data_schools(conn):
|
| 33 |
+
df_sch = pd.read_csv(sch_edp, sep=';')
|
| 34 |
+
df_sch.to_sql("tb_schools", conn, if_exists="replace")
|
| 35 |
+
df_sch = df_sch[:10]
|
| 36 |
+
return df_sch
|
| 37 |
|
| 38 |
+
@st.cache_resource
|
| 39 |
+
def refresh_data_students(conn):
|
| 40 |
+
df_std = pd.read_csv(std_edp)
|
| 41 |
+
df_std.to_sql("tb_students", conn, if_exists="replace")
|
| 42 |
+
df_std = df_std[:10]
|
| 43 |
+
return df_std
|
| 44 |
|
| 45 |
+
e1 = st.expander('Professores:', expanded=False)
|
| 46 |
+
with e1:
|
| 47 |
+
st.markdown('1 - Amostra de dados:')
|
| 48 |
+
st.dataframe(refresh_data_professors(conn=conn))
|
| 49 |
+
|
| 50 |
+
e2 = st.expander('Escolas:', expanded=False)
|
| 51 |
+
with e2:
|
| 52 |
+
st.markdown('1 - Amostra de dados:')
|
| 53 |
+
st.dataframe(refresh_data_schools(conn=conn))
|
| 54 |
|
| 55 |
+
e3 = st.expander('Estudantes:', expanded=False)
|
| 56 |
+
with e3:
|
| 57 |
+
st.markdown('1 - Amostra de dados:')
|
| 58 |
+
st.dataframe(refresh_data_students(conn=conn))
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
#sql = """SELECT alu_id, alu_nome, alu_uf, alu_cep, progresso_alfabetizacao FROM tb_students
|
| 65 |
+
# WHERE progresso_alfabetizacao >= 6 LIMIT 100"""
|
| 66 |
+
#dfp_std = pd.read_sql(sql, conn)
|
| 67 |
+
#st.dataframe(dfp_std)
|
| 68 |
+
#del dfp_std
|
| 69 |
+
#dfp_std.head(4)
|