Hi. I am new to dash and plotly. Basically what my code is trying to do is take the dataframe that is stored in a dictionary and place in dcc.store data. is there a reason I am getting an TypeError for dcc.store data?
Here is my code. The error is in the second callback.
Callbacks:
def upload_bcf_alert(data: Any) -> Any:
if ctx.triggered_id == "stored-bcf-data" and data:
return "Successful BCF Data Upload", True
elif (
ctx.triggered_id == "stored-bcf-data"
and data is not None
and len(data) == 0
):
return "BCF Data not uploaded successfully", True
else:
return no_update
@app.callback(
Output("bcf-dropdown", "options"),
Input("upload-bcf-data", "contents")
)
def bcf_dropdown(contents: str) -> Any | list:
"""
"""
if contents is None:
raise PreventUpdate
bcf_tabs, bcf_df_dict = adf_parser(contents)
return bcf_tabs
@app.callback(
Output("stored-bcf-data", "data"),
Input("bcf-dropdown", "value"),
Input("upload-bcf-data", "contents")
)
def bcf_tab_output(value: str, contents: str):
if contents is None:
raise PreventUpdate
if value is None:
raise PreventUpdate
bcf_tabs, bcf_dict = bcf_parser(contents)
bcf_select_df = bcf_dict[value]
return bcf_select_df.to_dict("records")
dash function that is called.
def bcf_parser(contents: str) -> object:
content_type, content_string = contents.split(",")
decoded = base64.b64decode(content_string)
bcf_obj = pad.BCFParser(io.BytesIO(decoded))
bcf_tabs = bcf_obj.bcf_sheetnames
bcf_df_dict = bcf_obj.bcf_dataframes
return bcf_tabs, bcf_df_dict
This is probably an easy fixâŚbut I just canât seem to understand why I am getting this:
**Callback error updating stored-adf-data.data
TypeError: unhashable type: âlistâ
**
BCFParser is a whole class⌠and basically it takes an excel file that has multiple sheets and places those sheets in dataframes and returns those dataframes as values in a dictionary.