Merge cells with st.dataframe or st.table

Can I merge cells when dataframe have multi column headers?

import streamlit as st
import pandas as pd

dataframe = pd.read_csv('test.csv')
data = dataframe.pivot_table(index=['type'], columns=['country','city'], values='payment', aggfunc='sum').reset_index()
st.table(data)

Hey @Fanstyone,

Thanks for sharing this question! Sorry for the late response.

st.table creates a static table, so you wouldn’t be able to merge cells. I’d recommend exploring st.experimental_data_editor and streamlit-aggrid for more flexibility.

A solution that worked for me was to convert the pandas DataFrame to HTML using DataFrame.to_html() and st.write() (with unsafe_allow_html=True)