Issue with download button

Hello, I have a code in which I give the app used the option to download data as a csv as follows:
st.download_button(label=‘:inbox_tray: Bajar Resultados’,
data=score_model ,
file_name= ‘Defaults.csv’)
where score_model is a pandas df.

I get the following error:
raise RuntimeError(“Invalid binary data format: %s” % type(data))

Does anyone undesrtand why?
Thank you

First try to add mime=“text/csv” to your st.download_button. If that doesn’t work, try to change your score_model to something like

score_model =score_model.to_csv(index=False).encode('utf-8')

ad then added the mime=“text/csv” option

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.