Skip to content

fix: Avoid using iter_rows in _check_dataframe_all_leaves to enable cuDF input #4878

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

Merged
merged 3 commits into from
Nov 22, 2024
Merged
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
22 changes: 13 additions & 9 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1851,16 +1851,20 @@ def _check_dataframe_all_leaves(df: nw.DataFrame) -> None:
null_mask=nw.any_horizontal(nw.all())
).get_column("null_mask")

for row_idx, row in zip(
null_indices_mask, null_mask.filter(null_indices_mask).iter_rows()
):
i = row.index(True)

if not all(row[i:]):
raise ValueError(
"None entries cannot have not-None children",
df_sorted.row(row_idx),
null_mask_filtered = null_mask.filter(null_indices_mask)
if not null_mask_filtered.is_empty():
for col_idx in range(1, null_mask_filtered.shape[1]):
# For each row, if a True value is encountered, then check that
# all values in subsequent columns are also True
null_entries_with_non_null_children = (
~null_mask_filtered[:, col_idx] & null_mask_filtered[:, col_idx - 1]
)
if nw.to_py_scalar(null_entries_with_non_null_children.any()):
row_idx = null_entries_with_non_null_children.to_list().index(True)
raise ValueError(
"None entries cannot have not-None children",
df_sorted.row(row_idx),
)

fill_series = nw.new_series(
name="fill_value",
Expand Down