I’m working on a streamlit app, need to use altair package to make long text in dataframe interact with other visuals. Leaving the interaction aside, I found the textwrap package does not seem to work in streamlit. Without it, long texts are truncated and incomplete.
import streamlit as st
import pandas as pd
import altair as alt
from textwrap import wrap
df[‘COMMENTSV2’] = df[‘COMMENTS’].astype(str)
df[‘COMMENTSV2’] = df[‘COMMENTSV2’].apply(wrap, args=)
alt.datum.row_number < 30
y=alt.Y(‘COMMENTSV2’, axis=alt.Axis(labelLimit=1000, labelFontSize=16, grid=False, labelAlign=‘left’
Notice the text have brackets and long text are truncated with 3 dots in the end. If I run the same code without streamlit, brackets are gone, full texts are wrapped without truncations. See screenshot below:
Everything else is exact the same. the only difference is the st.set_page_config, and st.altair_chart calls I have to make for streamlit to run. Has anyone experienced this before? Any suggestions are appreciated.