Textwrap does not work in streamlit?


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.

Steps to reproduce

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=[120])

alt.datum.row_number < 30

y=alt.Y(‘COMMENTSV2’, axis=alt.Axis(labelLimit=1000, labelFontSize=16, grid=False, labelAlign=‘left’
, maxExtent=1
, domain=False
, bandPosition=0
, title=‘’
, ticks=False)),

st.altair_chart(chart_1, use_container_width=True,theme=None)

After running it as streamlit app, it looks like this:

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.

Thank you