DataFrame.mask fails for single-row partitions https://github.com/dask/dask/issues/9848
(df, cond)
| 5202 | ], |
| 5203 | ) |
| 5204 | def test_mask_where_array_like(df, cond): |
| 5205 | """DataFrame.mask fails for single-row partitions |
| 5206 | https://github.com/dask/dask/issues/9848 |
| 5207 | """ |
| 5208 | ddf = dd.from_pandas(df, npartitions=2) |
| 5209 | |
| 5210 | # ensure raises when list is provided |
| 5211 | with pytest.raises(ValueError, match="can be aligned|shape"): |
| 5212 | ddf.mask(cond=cond, other=5) |
| 5213 | |
| 5214 | with pytest.raises(ValueError, match="can be aligned|shape"): |
| 5215 | ddf.where(cond=cond, other=5) |
| 5216 | |
| 5217 | # but works when DataFrame is provided, with matching index |
| 5218 | dd_cond = pd.DataFrame(cond, index=df.index, columns=df.columns) |
| 5219 | expected = df.mask(cond=cond, other=5) |
| 5220 | result = ddf.mask(cond=dd_cond, other=5) |
| 5221 | assert_eq(expected, result) |
| 5222 | |
| 5223 | expected = df.where(cond=cond, other=5) |
| 5224 | result = ddf.where(cond=dd_cond, other=5) |
| 5225 | assert_eq(expected, result) |
| 5226 | |
| 5227 | |
| 5228 | def test_mask_where_callable(): |