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)