plotly.py
plotly.py copied to clipboard
sunburst errors with "Non-leaves are not permitted in the dataframe"
The logic to check for non-leaves is dubious, e.g. a leaf whose name is a suffix of another leaf triggers an error. The check also depends on the alphabetical ordering on the leaves.
As suggested by #3589, I wonder whether this non-leaf detection is really meaningful. I'd be happy to write a PR to remove this check. Thoughts?
minimal working example
import pandas as pd
import plotly.express as px
df = pd.DataFrame(
{
"status": ["NOT_YET_COMPLETED", "COMPLETED"],
"next_step": ["Wrapup", None],
"count": [1, 2],
}
)
# no error
px.sunburst(df, path=["status", "next_step"], values="count")
df.loc[0, "status"] = "ACTIVE_NOT_YET_COMPLETED"
# error (spurious)
px.sunburst(df, path=["status", "next_step"], values="count")
@archmoj does this belong here or in plotly.js?
@LiamConnors would you please create a codepen and transfer it to plotly.js?
I think the dubious check in on the Python side, plotly/express/_core.py lines 1637 -- 1644.
@LiamConnors would you please create a codepen and transfer it to plotly.js?
The logic is in plotly.express and prevents the figure from being generated so it's not possible to create a codepen for plotly.js