Thanks to visit codestin.com
Credit goes to github.com

Skip to content

st.dataframe does not show pd.Categorical indices properly #9647

@zalgo3

Description

@zalgo3

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

If indices of a pandas dataframe has pd.Categorical type, st.dataframe seems not showing such indices properly. This behavior occurs for streamlit >= 1.32.0.

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st
import pandas as pd

data = [["a", 1], ["b", 2]]
df = pd.DataFrame(data, columns=["x", "y"])
df["x"] = pd.Categorical(df["x"], categories=["a", "b"])
st.dataframe(df.set_index("x"))

Steps To Reproduce

Run streamlit run <filename>.py

Expected Behavior

Column a should display "a" and "b" like the image below.

image

Current Behavior

Column a shows empty values as follows.

image

If you double-click the cell, the value is displayed.

image

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.39.0
  • Python version: 3.10.10
  • Operating System: Mac OS 15.0
  • Browser: Google Chrome

Additional Information

Downgrading to streamlit==1.31.1 removes this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:arrowRelated to Arrow data serializationfeature:st.dataframeRelated to the `st.dataframe` elementpriority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedupstreamIssue caused by upstream dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions