File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
packages/python/plotly/plotly/express Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -1851,16 +1851,20 @@ def _check_dataframe_all_leaves(df: nw.DataFrame) -> None:
18511851 null_mask = nw .any_horizontal (nw .all ())
18521852 ).get_column ("null_mask" )
18531853
1854- for row_idx , row in zip (
1855- null_indices_mask , null_mask .filter (null_indices_mask ).iter_rows ()
1856- ):
1857- i = row .index (True )
1858-
1859- if not all (row [i :]):
1860- raise ValueError (
1861- "None entries cannot have not-None children" ,
1862- df_sorted .row (row_idx ),
1854+ null_mask_filtered = null_mask .filter (null_indices_mask )
1855+ if not null_mask_filtered .is_empty ():
1856+ for col_idx in range (1 , null_mask_filtered .shape [1 ]):
1857+ # For each row, if a True value is encountered, then check that
1858+ # all values in subsequent columns are also True
1859+ null_entries_with_non_null_children = (
1860+ ~ null_mask_filtered [:, col_idx ] & null_mask_filtered [:, col_idx - 1 ]
18631861 )
1862+ if nw .to_py_scalar (null_entries_with_non_null_children .any ()):
1863+ row_idx = null_entries_with_non_null_children .to_list ().index (True )
1864+ raise ValueError (
1865+ "None entries cannot have not-None children" ,
1866+ df_sorted .row (row_idx ),
1867+ )
18641868
18651869 fill_series = nw .new_series (
18661870 name = "fill_value" ,
You can’t perform that action at this time.
0 commit comments