add list filtering
Browse files- appStore/target.py +11 -10
appStore/target.py
CHANGED
@@ -96,7 +96,7 @@ def target_display():
|
|
96 |
if range_val !=0:
|
97 |
# collecting some statistics
|
98 |
count_target = sum(hits['Target Label'] == 'TARGET')
|
99 |
-
count_netzero = sum(hits['Netzero Label'] == '
|
100 |
count_ghg = sum(hits['GHG Label'] == 'GHG')
|
101 |
count_transport = sum([True if 'Transport' in x else False
|
102 |
for x in hits['Sector Label']])
|
@@ -198,7 +198,15 @@ def filter_dataframe(df: pd.DataFrame) -> pd.DataFrame:
|
|
198 |
left, right = st.columns((1, 20))
|
199 |
left.write("↳")
|
200 |
# Treat columns with < 10 unique values as categorical
|
201 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
user_cat_input = right.multiselect(
|
203 |
f"Values for {column}",
|
204 |
df[column].unique(),
|
@@ -217,14 +225,7 @@ def filter_dataframe(df: pd.DataFrame) -> pd.DataFrame:
|
|
217 |
step=step,
|
218 |
)
|
219 |
df = df[df[column].between(*user_num_input)]
|
220 |
-
|
221 |
-
list_vals = set(tuple(x) for x in df[column].tolist())
|
222 |
-
user_multi_input = right.multiselect(
|
223 |
-
f"Values for {column}",
|
224 |
-
list_vals,
|
225 |
-
default=list_vals,
|
226 |
-
)
|
227 |
-
df = df[df[column].str.contains(user_multi_input)]
|
228 |
# df[df[column].between(*user_num_input)]
|
229 |
# elif is_datetime64_any_dtype(df[column]):
|
230 |
# user_date_input = right.date_input(
|
|
|
96 |
if range_val !=0:
|
97 |
# collecting some statistics
|
98 |
count_target = sum(hits['Target Label'] == 'TARGET')
|
99 |
+
count_netzero = sum(hits['Netzero Label'] == 'NETZERO TARGET')
|
100 |
count_ghg = sum(hits['GHG Label'] == 'GHG')
|
101 |
count_transport = sum([True if 'Transport' in x else False
|
102 |
for x in hits['Sector Label']])
|
|
|
198 |
left, right = st.columns((1, 20))
|
199 |
left.write("↳")
|
200 |
# Treat columns with < 10 unique values as categorical
|
201 |
+
if is_list_like(df[column]):
|
202 |
+
list_vals = set(tuple(x) for x in df[column].tolist())
|
203 |
+
user_multi_input = right.multiselect(
|
204 |
+
f"Values for {column}",
|
205 |
+
list_vals,
|
206 |
+
default=list_vals,
|
207 |
+
)
|
208 |
+
df = df[df[column].str.contains(user_multi_input)]
|
209 |
+
elif is_categorical_dtype(df[column]) or df[column].nunique() < 10:
|
210 |
user_cat_input = right.multiselect(
|
211 |
f"Values for {column}",
|
212 |
df[column].unique(),
|
|
|
225 |
step=step,
|
226 |
)
|
227 |
df = df[df[column].between(*user_num_input)]
|
228 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
# df[df[column].between(*user_num_input)]
|
230 |
# elif is_datetime64_any_dtype(df[column]):
|
231 |
# user_date_input = right.date_input(
|