Search code examples
pandasdataframestreamlit

Text gets truncated while using streamlit.write(df)


I'm using the function streamlit.write(df) to display a df, but the text is not fully displayed, here is a short example of the situation.

import pandas as pd
import streamlit as st

df = pd.DataFrame({'col1': [1, 2, 3], 'col2': ['This is some text large text that will not be 
                  completely displayed, need to add break lines or something.', 'short text', 
                  'another piece of text.']})
st.write(df))

This is the output, the ideal thing is to add line breaks, but did not work for me.

enter image description here


Solution

  • You can use table

    st.table(df)