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
{{ message }}
Repository navigation
[BUG]: px raises "boolean value of NA is ambiguous" for nullable-dtype grouping columns with missing values #5895
Plotly Express raises TypeError: boolean value of NA is ambiguous when a column with a nullable pandas dtype contains a missing value and is used as a grouping argument. This happens for color, symbol, line_dash, line_group, facet_row, facet_col, animation_frame and pattern_shape, and for the dtypes string, boolean, Int64, Float64, string[pyarrow] and pd.ArrowDtype(pa.string()). Columns of dtype object, float, category and the pandas 3 default str work. A common way to get these dtypes is df.convert_dtypes().
Screenshots/Video
None.
Steps to reproduce
Tested with plotly 7.1.0 and pandas 2.3.3 and 3.1.1.
Actual: TypeError: boolean value of NA is ambiguous.
Expected: two traces, u (x=[1, 4]) and v (x=[3]). The row with the missing value is dropped, as it is when g has dtype object.
Notes
The cause is in plotly/express/_core.py. The sort of the groups and of the animation frames uses list.index and in on the unique values, which compare pd.NA with ==.
Activity