Spaces:
Sleeping
Sleeping
Update pages/2_⏱️_Tiempos muertos.py
Browse files
pages/2_⏱️_Tiempos muertos.py
CHANGED
@@ -30,9 +30,9 @@ def get_points(fecha1:str, fecha2:str, id_camion:int):
|
|
30 |
,((received_json -> 'position') ->> 'lat') :: NUMERIC AS lat
|
31 |
,((received_json -> 'position') ->> 'lng') :: NUMERIC AS lng
|
32 |
,(saved_at AT time ZONE 'utc' AT TIME ZONE 'cst') AS saved_at
|
|
|
33 |
FROM json_dump jd
|
34 |
WHERE (saved_at AT time ZONE 'utc' AT TIME ZONE 'cst') :: date BETWEEN '{fecha1}' AND '{fecha2}'
|
35 |
-
AND (saved_at AT time ZONE 'utc' AT TIME ZONE 'cst') :: time BETWEEN '05:00:00' AND '22:00:00'
|
36 |
AND ((received_json -> 'position') ->> 'device_id') :: NUMERIC = '{id_camion}'
|
37 |
ORDER BY ((received_json -> 'position') ->> 'device_id') :: NUMERIC, saved_at
|
38 |
"""
|
@@ -104,7 +104,7 @@ with st.sidebar:
|
|
104 |
inicio_fecha = st.date_input(label="Fecha de inicio")
|
105 |
final_fecha = st.date_input(label="Fecha final")
|
106 |
id_camion = st.selectbox(label="Seleccione un vehiculo:", options=[13, 14, 15])
|
107 |
-
hexagono_size = st.slider(label="Tamaño de hexagonos", min_value=0, max_value=15, step=1, value=11)
|
108 |
|
109 |
estadistica = st.form_submit_button("Enviar")
|
110 |
|
@@ -116,7 +116,7 @@ if not df_puntos.empty:
|
|
116 |
|
117 |
df_puntos.loc[:, ("id_hexagono")] = df_puntos.apply(lambda x: h3.geo_to_h3(x.lat, x.lng, hexagono_size), 1)
|
118 |
|
119 |
-
df_agg = df_puntos.groupby(["id_hexagono", "fecha", "device_id"], as_index=False).agg(num_registro=('id_hexagono', 'count'), max_hora=("saved_at", "max"), min_hora=("saved_at", "min")).reset_index()
|
120 |
df_agg["diff_tiempo"] = (df_agg["max_hora"] - df_agg["min_hora"]).astype('timedelta64[s]').dt.total_seconds() / 60
|
121 |
df_agg["diff_tiempo"] = df_agg["diff_tiempo"].round(2)
|
122 |
|
|
|
30 |
,((received_json -> 'position') ->> 'lat') :: NUMERIC AS lat
|
31 |
,((received_json -> 'position') ->> 'lng') :: NUMERIC AS lng
|
32 |
,(saved_at AT time ZONE 'utc' AT TIME ZONE 'cst') AS saved_at
|
33 |
+
,((received_json -> 'position') ->> 'angle') :: int AS angle
|
34 |
FROM json_dump jd
|
35 |
WHERE (saved_at AT time ZONE 'utc' AT TIME ZONE 'cst') :: date BETWEEN '{fecha1}' AND '{fecha2}'
|
|
|
36 |
AND ((received_json -> 'position') ->> 'device_id') :: NUMERIC = '{id_camion}'
|
37 |
ORDER BY ((received_json -> 'position') ->> 'device_id') :: NUMERIC, saved_at
|
38 |
"""
|
|
|
104 |
inicio_fecha = st.date_input(label="Fecha de inicio")
|
105 |
final_fecha = st.date_input(label="Fecha final")
|
106 |
id_camion = st.selectbox(label="Seleccione un vehiculo:", options=[13, 14, 15])
|
107 |
+
hexagono_size = 10#st.slider(label="Tamaño de hexagonos", min_value=0, max_value=15, step=1, value=11)
|
108 |
|
109 |
estadistica = st.form_submit_button("Enviar")
|
110 |
|
|
|
116 |
|
117 |
df_puntos.loc[:, ("id_hexagono")] = df_puntos.apply(lambda x: h3.geo_to_h3(x.lat, x.lng, hexagono_size), 1)
|
118 |
|
119 |
+
df_agg = df_puntos.groupby(["id_hexagono", "fecha", "device_id", "angle"], as_index=False).agg(num_registro=('id_hexagono', 'count'), max_hora=("saved_at", "max"), min_hora=("saved_at", "min")).reset_index()
|
120 |
df_agg["diff_tiempo"] = (df_agg["max_hora"] - df_agg["min_hora"]).astype('timedelta64[s]').dt.total_seconds() / 60
|
121 |
df_agg["diff_tiempo"] = df_agg["diff_tiempo"].round(2)
|
122 |
|