Hey everyone!
I am trying to display contents of a pandas dataframe within a designated container. This is my code:
data = {
'name': ['A', 'B', 'C'],
'date': ['A', 'B', 'C'],
'amount': ['A', 'B', 'C'],
'description': ['A', 'B', 'C'],
'category': ['A', 'B', 'C'],
}
tr_df = pd.DataFrame(data)
container_html = '<div class="content-container">'
for index, row in tr_df.iterrows():
container_html += f"""
<div class="data-container">
<h3 class="data-field">{row['name']}</h3>
<p class="data-field"><span class="data-label">Date:</span> {row['date']}</p>
<p class="data-field"><span class="data-label">Amount:</span> {row['amount']}</p>
<p class="data-field"><span class="data-label">Description:</span> {row['description']}</p>
<p class="data-field"><span class="data-label">Category:</span> <span class="data-value">{row['category']}</span></p>
</div>
"""
container_html += '</div>' # Close the main content container
st.markdown(container_html, unsafe_allow_html=True)
however, it is displayed like this:
(the first dataframe row is displayed correctly, but all following rows are displayed as plain text and not rendered correctly.)
I am running the app locally.
Any hints on what can be improved here?
Kind regards,
Max