Skip to content

Commit da0a4f4

Browse files
committed
remove check for non-leaf node
fixes plotly#4774 and plotly#3589
1 parent 673c19c commit da0a4f4

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

packages/python/plotly/plotly/express/_core.py

-9
Original file line numberDiff line numberDiff line change
@@ -1633,15 +1633,6 @@ def _check_dataframe_all_leaves(df):
16331633
"None entries cannot have not-None children",
16341634
df_sorted.iloc[null_row_index],
16351635
)
1636-
df_sorted[null_mask] = ""
1637-
row_strings = list(df_sorted.apply(lambda x: "".join(x), axis=1))
1638-
for i, row in enumerate(row_strings[:-1]):
1639-
if row_strings[i + 1] in row and (i + 1) in null_indices:
1640-
raise ValueError(
1641-
"Non-leaves rows are not permitted in the dataframe \n",
1642-
df_sorted.iloc[i + 1],
1643-
"is not a leaf.",
1644-
)
16451636

16461637

16471638
def process_dataframe_hierarchy(args):

packages/python/plotly/plotly/tests/test_optional/test_px/test_px_functions.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,25 @@ def test_sunburst_treemap_with_path_non_rectangular():
320320
)
321321
)
322322
path = ["total", "regions", "sectors", "vendors"]
323-
msg = "Non-leaves rows are not permitted in the dataframe"
324-
with pytest.raises(ValueError, match=msg):
325-
fig = px.sunburst(df, path=path, values="values")
323+
fig = px.sunburst(df, path=path, values="values")
324+
assert fig.data[0].values[-1] == np.sum(values)
326325
df.loc[df["vendors"].isnull(), "sectors"] = "Other"
327326
fig = px.sunburst(df, path=path, values="values")
328327
assert fig.data[0].values[-1] == np.sum(values)
329328

329+
df = pd.DataFrame(
330+
{
331+
"status": ["NOT_YET_COMPLETED", "COMPLETED"],
332+
"next_step": ["Wrapup", None],
333+
"count": [1, 2],
334+
}
335+
)
336+
fig = px.sunburst(df, path=["status", "next_step"], values="count")
337+
assert fig.data[0].values[-1] == 3
338+
df.loc[0, "status"] = "ACTIVE_NOT_YET_COMPLETED"
339+
fig = px.sunburst(df, path=["status", "next_step"], values="count")
340+
assert fig.data[0].values[-1] == 3
341+
330342

331343
def test_pie_funnelarea_colorscale():
332344
labels = ["A", "B", "C", "D"]

0 commit comments

Comments
 (0)