I am trying to display a pivot_table in streamlit but the dataframe is not properly displayed (See pictures below).
Note: The data used here is junk data I created to add some clarity to this example, as nobody replied to this issue after more than 24 hours.
Steps to reproduce
import streamlit as st import pandas as pd import calendar import sys def read_csv(PATH: str) -> pd.DataFrame: try: df = pd.read_csv(PATH) except: sys.exit('Unable to read the data, kindly verify the source and try again') abbr = dict(enumerate(calendar.month_abbr)) abbr.pop(0) df['MONTH'] = pd.Categorical(df['MONTH'], categories=list(abbr.values()), ordered=True) return df with st.sidebar: st.info('This is my first web appliaction with streamlit') PATH = 'https://raw.githubusercontent.com/Lamy237/hello-world/main/pay.csv' df = read_csv(PATH) monthly_pay_df = df.pivot_table(values='PAY', index='MONTH', columns='YEAR') st.dataframe(monthly_pay_df, use_container_width=True)
I want the dataframe to be displayed the following way:
However, this is what I get on streamlit.
As you can see, not only the cell containing YEAR was removed but I also get several warnings in the MONTH column.
- Streamlit version: latest
- Python version: 3.11.1
- OS version: Windows 10