From 7e2cc2542cea2cc61844f337515f04900a937756 Mon Sep 17 00:00:00 2001 From: alephcero Date: Fri, 22 Nov 2024 14:54:19 -0300 Subject: [PATCH] Add amount of lines to the basic kpi query --- urbantrips/viz/viz.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/urbantrips/viz/viz.py b/urbantrips/viz/viz.py index c46fb52..35d45c2 100755 --- a/urbantrips/viz/viz.py +++ b/urbantrips/viz/viz.py @@ -2625,15 +2625,13 @@ def plot_basic_kpi_wrapper(): q = """ select * from basic_kpi_by_line_hr - where dia = 'weekday' + where dia = 'weekday'; """ - if lineas_principales != "All": - q += f"limit {lineas_principales}" - - q += ";" - kpi_data = pd.read_sql(q, conn_data) + if lineas_principales != "All": + top_lines = list(kpi_data.id_linea.value_counts().index[:lineas_principales]) + kpi_data = kpi_data.loc[kpi_data.id_linea.isin(top_lines)] if len(kpi_data) > 0: kpi_data.groupby(["id_linea", "yr_mo"]).apply(