In st.write() : TypeError: exception() takes 3 positional arguments but 4 were given

Hi guys!
I am getting an error if I try to use st.write() for 2 different dataframes. It works if I try to write the same data, but I get the following error if I try to write a different dataframe. I leave my code further below. Thanks!!.

ERROR:
TypeError: exception() takes 3 positional arguments but 4 were given

File "C:\\dashboard.py", line 101, in main
    st.write(preds.head())File "C:\\AppData\Local\Programs\Python\Python37\lib\site-packages\streamlit\__init__.py", line 411, in write
    exception(exc, exc_tb)  # noqa: F821

CODE:
def main():

raw_data = load_data_rows(100)
new_data = raw_data.copy()
st.subheader('RawData')
st.write(new_data.head())

preds = pd.read_pickle('preds.pkl')
st.subheader('Predictions') 
st.write(preds.head())

Hi Rat,

I do not think you are the first to encounter this issue! There is an open issue here and a previous thread here. Perhaps some of the answers there can help you debuggingโ€ฆ It looks like it has something to do with the preds dataframe, but that is all I can say.

2 Likes

Thanks PeterT! Iโ€™ll take a look :grin:

Hi again!
After I donโ€™t know how many hours, I have fixed it adding .astype('object').

I hope it helps someone :slight_smile:

See you soon!

2 Likes

Thanks for sharing the answer @Rat, and welcome to the Streamlit Community!

Best,
Randy

1 Like