You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not urgent, let's wait until after pydantic v2 to fix.
If a column contains only numerical values but is object type (as can happen when you load data from a file) then it's correctly considered a categorical variable so given selector vm.Dropdown by default. However, filtering on it won't work.
The root cause is:
pydantic model has OptionsType = Union[list[StrictBool], list[float], list[str], list[date], list[OptionsDictType]] and casts options to float
_filter_isin is then comparing series of objects to float, which doesn't return anything
This is a problem with at least Dropdown, Checklist, RadioItems and probably affects more than just numerical types.
Possible fixes:
change order of Union in pydantic field definition but without breaking anything else so need to be careful
importvizro.modelsasvmimportpandasaspdfromvizroimportVizrofromvizro.tablesimportdash_ag_griddf=pd.DataFrame({"my_column": ["1", "2", "3"]})
# Uncomment this line to see the bug# df["my_column"] = df["my_column"].astype(int)page=vm.Page(
title="Bug",
components=[vm.AgGrid(figure=dash_ag_grid(data_frame=df))],
controls=[vm.Filter(column="my_column", selector=vm.RadioItems())],
)
dashboard=vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
Which package?
vizro
Package version
0.1.26
Description
Note
Not urgent, let's wait until after pydantic v2 to fix.
If a column contains only numerical values but is
object
type (as can happen when you load data from a file) then it's correctly considered a categorical variable so given selectorvm.Dropdown
by default. However, filtering on it won't work.The root cause is:
OptionsType = Union[list[StrictBool], list[float], list[str], list[date], list[OptionsDictType]]
and casts options tofloat
_filter_isin
is then comparing series ofobject
s tofloat
, which doesn't return anythingThis is a problem with at least Dropdown, Checklist, RadioItems and probably affects more than just numerical types.
Possible fixes:
Union
in pydantic field definition but without breaking anything else so need to be careful_filter_isin
that does conversionsRangeSlider
should be usable for ordinal data. Also understand thebool
case from __call__ function within models/_components/graphy.py passing parent function kwargs unintentionally #445How to Reproduce
PyCafe snippet
Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: