Skip to content

Pandas CategoricalIndex not supported #47

@monchier

Description

@monchier

Summary

Pandas supports a Categorical Index datatype. When using st.write(dataframe), if the dataframe contains some categorical data an error is generated.

Steps to reproduce

Create a dataframe with a Categorical Index. For example: uses pd.cut to segment existing numerical data (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.cut.html)
This is a snippet that takes a median_income column and segments it (from https://github.com/ageron/handson-ml/blob/master/02_end_to_end_machine_learning_project.ipynb row 22)

Expected behavior:

No error. The dataframe is shown in the UI.

Actual behavior:

st.write(df['income_cat'])
NotImplementedError: Can't handle <class 'pandas.core.indexes.category.CategoricalIndex'> yet.
st.write(df['income_cat'].value_counts())```
## Is this a regression?
Not that I know

# Debug info
- Streamlit version: Streamlit v0.45.0
- Python version: 3.7.4
- Using Conda? PipEnv? PyEnv? Pex?
- OS version: MacOs 10.14.6
- Browser version: Chrome  76.0.3809.100

# Additional information
If needed, add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

area:arrowRelated to Arrow data serializationfeature:st.dataframeRelated to the `st.dataframe` elementtype:enhancementRequests for feature enhancements or new features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions