The option category_orders for pie in Plotly Express does not work when using a bool field in pandas. Here's an example
>>> import pandas as pd
>>> import plotly.express as px
>>> df = pd.DataFrame({'B': [False, True, False]})
>>> df
B
0 | False
1 | True
2 | False
>>> px.pie(
df,
names='B',
category_orders={'B':[True, False]}
)
The above code breaks with the following error
IndexError: Boolean index has wrong length: 2 instead of 3
Everything works fine when casting the bool field to str or int.
Libraries used:
- plotly==5.9.0
- pandas==1.4.3
The option
category_ordersforpiein Plotly Express does not work when using aboolfield inpandas. Here's an exampleThe above code breaks with the following error
Everything works fine when casting the bool field to
strorint.Libraries used: