mejoramiento en gráficas de principales

- solo se muestran los alimentos con mayores apariciones
- tanto los anteriores como las categorias se muestran en orden
- descendente
parent 2484d45a
...@@ -350,22 +350,28 @@ def comidas_porcentajes(datos): ...@@ -350,22 +350,28 @@ def comidas_porcentajes(datos):
return figura return figura
def comidas_principales(datos): def comidas_principales(datos):
dominantes = datos.groupby("dominante") dominantes = datos.groupby("dominante").count()
categorias = datos.groupby("dominante_category") dominantes.sort_values(by="patient", ascending=False, inplace=True)
figura = make_subplots(cols=1, rows=1) dominantes = dominantes[dominantes["patient"] > 9]
figura = make_subplots(cols=1, rows=1, subplot_titles= ["Alimentos"])
figura.add_trace( figura.add_trace(
go.Scatter(x=list(dominantes.groups.keys()), y=dominantes.count()["patient"], mode='markers'), go.Scatter(x=dominantes.index, y=dominantes["patient"], mode='markers', name="# de comidas"),
col=1, row=1 col=1, row=1
) )
figura["layout"]['yaxis']['title']= "# de comidas"
# figura.update_layout(height=2000, width=800)
return figura return figura
def comidas_principales_categorias(datos): def comidas_principales_categorias(datos):
categorias = datos.groupby("dominante_category") categorias = datos.groupby("dominante_category").count()
figura = make_subplots(cols=1, rows=1) categorias.sort_values(by="patient", ascending=False, inplace=True)
categorias = categorias[categorias["patient"] > 9]
figura = make_subplots(cols=1, rows=1, subplot_titles=["Categorías de alimentos"])
figura.add_trace( figura.add_trace(
go.Scatter(x=list(categorias.groups.keys()), y=categorias.count()["patient"], mode='markers'), go.Scatter(x=categorias.index, y=categorias["patient"], mode='markers'),
col=1, row=1 col=1, row=1
) )
figura["layout"]['yaxis']['title']= "# de comidas"
return figura return figura
def comidas_principales_hists(datos): def comidas_principales_hists(datos):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment