Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove check for non-leaf node #4776

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

- Updated Plotly.js from version 2.35.0 to version 2.35.2. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2352----2024-09-10) for more information.

### Fixed
- Removed check for non-leaf nodes in dataframe for sunburst, treemap, and icicle [[#4776](https://github.com/plotly.plotly.py/pull/4776)]

## [5.24.0] - 2024-08-29

### Added
Expand Down
9 changes: 0 additions & 9 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,15 +1633,6 @@ def _check_dataframe_all_leaves(df):
"None entries cannot have not-None children",
df_sorted.iloc[null_row_index],
)
df_sorted[null_mask] = ""
row_strings = list(df_sorted.apply(lambda x: "".join(x), axis=1))
for i, row in enumerate(row_strings[:-1]):
if row_strings[i + 1] in row and (i + 1) in null_indices:
raise ValueError(
"Non-leaves rows are not permitted in the dataframe \n",
df_sorted.iloc[i + 1],
"is not a leaf.",
)


def process_dataframe_hierarchy(args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,25 @@ def test_sunburst_treemap_with_path_non_rectangular():
)
)
path = ["total", "regions", "sectors", "vendors"]
msg = "Non-leaves rows are not permitted in the dataframe"
with pytest.raises(ValueError, match=msg):
fig = px.sunburst(df, path=path, values="values")
fig = px.sunburst(df, path=path, values="values")
assert fig.data[0].values[-1] == np.sum(values)
df.loc[df["vendors"].isnull(), "sectors"] = "Other"
fig = px.sunburst(df, path=path, values="values")
assert fig.data[0].values[-1] == np.sum(values)

df = pd.DataFrame(
{
"status": ["NOT_YET_COMPLETED", "COMPLETED"],
"next_step": ["Wrapup", None],
"count": [1, 2],
}
)
fig = px.sunburst(df, path=["status", "next_step"], values="count")
assert fig.data[0].values[-1] == 1
df.loc[0, "status"] = "ACTIVE_NOT_YET_COMPLETED"
fig = px.sunburst(df, path=["status", "next_step"], values="count")
assert fig.data[0].values[-1] == 2


def test_pie_funnelarea_colorscale():
labels = ["A", "B", "C", "D"]
Expand Down