File tree 1 file changed +13
-9
lines changed
packages/python/plotly/plotly/express
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:
1851
1851
null_mask = nw .any_horizontal (nw .all ())
1852
1852
).get_column ("null_mask" )
1853
1853
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 ]
1863
1861
)
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
+ )
1864
1868
1865
1869
fill_series = nw .new_series (
1866
1870
name = "fill_value" ,
You can’t perform that action at this time.
0 commit comments