Spaces:
Sleeping
Sleeping
Jon Solow
commited on
Commit
·
c19d238
1
Parent(s):
99d7007
fix check on streamlit filter for pd deprecation
Browse files- src/streamlit_filter.py +1 -2
src/streamlit_filter.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
# https://blog.streamlit.io/auto-generate-a-dataframe-filtering-ui-in-streamlit-with-filter_dataframe/
|
2 |
|
3 |
from pandas.api.types import (
|
4 |
-
is_categorical_dtype,
|
5 |
is_datetime64_any_dtype,
|
6 |
is_numeric_dtype,
|
7 |
is_object_dtype,
|
@@ -48,7 +47,7 @@ def filter_dataframe(df: pd.DataFrame, force_on: bool = False, force_on_columns:
|
|
48 |
for column in to_filter_columns:
|
49 |
left, right = st.columns((1, 20))
|
50 |
# Treat columns with < 17 unique values as categorical
|
51 |
-
if
|
52 |
user_cat_input = right.multiselect(
|
53 |
f"Values for {column}",
|
54 |
df[column].unique(),
|
|
|
1 |
# https://blog.streamlit.io/auto-generate-a-dataframe-filtering-ui-in-streamlit-with-filter_dataframe/
|
2 |
|
3 |
from pandas.api.types import (
|
|
|
4 |
is_datetime64_any_dtype,
|
5 |
is_numeric_dtype,
|
6 |
is_object_dtype,
|
|
|
47 |
for column in to_filter_columns:
|
48 |
left, right = st.columns((1, 20))
|
49 |
# Treat columns with < 17 unique values as categorical
|
50 |
+
if isinstance(df[column].dtype, pd.CategoricalDtype) or df[column].nunique() < 50:
|
51 |
user_cat_input = right.multiselect(
|
52 |
f"Values for {column}",
|
53 |
df[column].unique(),
|