Skip to content

Commit 50b5b88

Browse files
Merge pull request #640 from ZakariaRida96/hotfix/webapp_filter_date
Fix Date Filtering and Improve Boolean Type Handling in Shapash Webapp
2 parents 509ecb6 + 6d85fed commit 50b5b88

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

shapash/webapp/utils/callbacks.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -635,10 +635,10 @@ def create_filter_modalities_selection(value: str, id: dict, round_dataframe: pd
635635
html.Div
636636
Div containing the modalities selection options
637637
"""
638-
if type(round_dataframe[value].iloc[0]) == bool:
638+
if type(round_dataframe[value].iloc[0]) is np.bool_ or type(round_dataframe[value].iloc[0]) is bool:
639639
new_element = html.Div(
640640
dcc.RadioItems(
641-
[{"label": val, "value": val} for val in round_dataframe[value].unique()],
641+
[{"label": str(val), "value": val} for val in round_dataframe[value].unique()],
642642
id={"type": "dynamic-bool", "index": id["index"]},
643643
value=round_dataframe[value].iloc[0],
644644
inline=False,
@@ -659,17 +659,16 @@ def create_filter_modalities_selection(value: str, id: dict, round_dataframe: pd
659659
elif (type(round_dataframe[value].iloc[0]) is pd.Timestamp) | (
660660
type(round_dataframe[value].iloc[0]) is datetime.datetime
661661
):
662-
new_element = (
663-
html.Div(
664-
dcc.DatePickerRange(
665-
id={"type": "dynamic-date", "index": id["index"]},
666-
min_date_allowed=round_dataframe[value].min(),
667-
max_date_allowed=round_dataframe[value].max(),
668-
start_date=round_dataframe[value].min(),
669-
end_date=round_dataframe[value].max(),
670-
),
671-
style={"width": "65%", "margin-left": "20px"},
662+
new_element = html.Div(
663+
dcc.DatePickerRange(
664+
id={"type": "dynamic-date", "index": id["index"]},
665+
min_date_allowed=round_dataframe[value].min(),
666+
max_date_allowed=round_dataframe[value].max(),
667+
start_date=round_dataframe[value].min(),
668+
end_date=round_dataframe[value].max(),
669+
clearable=True,
672670
),
671+
style={"width": "65%", "margin-left": "20px"},
673672
)
674673
else:
675674
lower_value = 0

0 commit comments

Comments
 (0)