Pandas supports a _Categorical Index_ datatype. When using st.write(dataframe), if the dataframe contains some categorical data an error is generated.
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)
df['income_cat'] = pd.cut(df['median_income'], bins=[0., 1.5, 3.0, 4.5, 6., np.inf], labels=[1, 2, 3, 4, 5])
No error. The dataframe is shown in the UI.
NotImplementedError: Dtype category not understood.
st.write(df['income_cat'])
NotImplementedError: Can't handle <class 'pandas.core.indexes.category.CategoricalIndex'> yet.
st.write(df['income_cat'].value_counts())
Not that I know
If needed, add any other context about the problem here.
Workaround for now:
st.write(df.astype('object'))
I think @kantuni's Arrow work will address this
Related #453
Most helpful comment
Workaround for now:
st.write(df.astype('object'))