File size: 1,182 Bytes
d345661 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | """UI logic for the "Estadístiques" page."""
from __future__ import annotations
import pandas as pd
import streamlit as st
from database import get_feedback_ad_stats
def render_statistics_page() -> None:
st.header("Estadístiques")
stats = get_feedback_ad_stats()
if not stats:
st.caption("Encara no hi ha valoracions.")
st.stop()
df = pd.DataFrame(stats, columns=stats[0].keys())
ordre = st.radio(
"Ordre de rànquing",
["Descendent (millors primer)", "Ascendent (pitjors primer)"],
horizontal=True,
)
if ordre.startswith("Asc"):
df = df.sort_values("avg_global", ascending=True)
else:
df = df.sort_values("avg_global", ascending=False)
st.subheader("Rànquing de vídeos")
st.dataframe(
df[
[
"video_name",
"n",
"avg_global",
"avg_transcripcio",
"avg_identificacio",
"avg_localitzacions",
"avg_activitats",
"avg_narracions",
"avg_expressivitat",
]
],
use_container_width=True,
)
|