Hello all,
New here, first post, blah blah, you know the drill.
I have a digital pill tracker app that I would like to enhance with visualization. This is all categorical data, so no aggfunc. I can always follow the instructions for the basic number based plots without issue. When I get to the categoricals, especially with my own data, the wheels come off. I have NEVER executed a successful plot with my own data. Never. Not with lines, not with bars, not with scatters, not with heatmaps. Not with matplotlib, not with altair, not with bokeh, and frustratingly, now not with plotly, either.
If I knew what was wrong, I wouldnât be here. If I hadnât tried everything I knew to try, I wouldnât be here. If I knew what the next move should be, I wouldnât be here.
most recent version of my script:
from dash import Dash, dcc, html, Input, Output
import plotly.express as px
import pandas as pd
app = Dash(__name__)
app.layout = html.Div([
html.H4("Medical Compliance Log"),
dcc.Graph(id="graph"),
html.P("Meds included:"),
dcc.Checklist(
id="meds",
options=["alphastim", "amlodipine", "ammonium_lactate"],
value=["alphastim", "amlodipine", "ammonium_lactate"],
),
])
cols = ["alphastim", "amlodipine", "ammonium_lactate"]
@app.callback(
Output("graph", "figure"),
Input("meds", "value"))
def filter_heatmap(cols):
taken = []
time = ["2022-04-19", "2022-04-20", "2022-04-21"]
df = pd.read_csv("choice hex - choices.csv")
df['days'] = time
for column in df.columns:
taken.append(pd.Series(column))
# taken.append(df[column])
df['taken'] = taken
df.groupby(self=cols)
df = df.pivot("days", cols, taken)
fig = px.imshow(df[cols])
# why is this df[cols]? why not the whole df?
return fig
app.run_server(debug=True)
csv:
âalphastimâ,âamlodipineâ,âammonium_lactateâ,âcaffeineâ,âdesvenlafaxineâ,âdicyclomineâ,âgasxâ,âkaopectateâ,âlinzessâ,âmagnesiumâ,âmiralaxâ,âmodafinilâ,ânaproxenâ,âvaporubâ
âYesâ,âNoâ,âNoâ,âYesâ,âNot Requiredâ,âNot Requiredâ,âNot Requiredâ,âNot Recordedâ,âNoâ,âNoâ,âNot Recordedâ,âNot Recordedâ,âNot Recordedâ,âYesâ
âYesâ,âNot Recordedâ,âNoâ,âNot Requiredâ,âNot Requiredâ,âYesâ,âNot Recordedâ,âNot Requiredâ,âNoâ,âNot Recordedâ,âNoâ,âNot Recordedâ,âNot Requiredâ,âNoâ
âNot Requiredâ,âNoâ,âNoâ,âYesâ,âNoâ,âNot Recordedâ,âNot Recordedâ,âNot Requiredâ,âNot Requiredâ,âYesâ,âNot Recordedâ,âNoâ,âNot Recordedâ,âYesâ
most recent error (which I thought groupby and/or pivot would fix):
ValueError: Length of values (15) does not match length of index (3)