DataFrame.mask fails for single-row partitions https://github.com/dask/dask/issues/9848
(df, cond)
| 5181 | ], |
| 5182 | ) |
| 5183 | def test_mask_where_array_like(df, cond): |
| 5184 | """DataFrame.mask fails for single-row partitions |
| 5185 | https://github.com/dask/dask/issues/9848 |
| 5186 | """ |
| 5187 | ddf = dd.from_pandas(df, npartitions=2) |
| 5188 | |
| 5189 | # ensure raises when list is provided |
| 5190 | with pytest.raises(ValueError, match="can be aligned|shape"): |
| 5191 | ddf.mask(cond=cond, other=5) |
| 5192 | |
| 5193 | with pytest.raises(ValueError, match="can be aligned|shape"): |
| 5194 | ddf.where(cond=cond, other=5) |
| 5195 | |
| 5196 | # but works when DataFrame is provided, with matching index |
| 5197 | dd_cond = pd.DataFrame(cond, index=df.index, columns=df.columns) |
| 5198 | expected = df.mask(cond=cond, other=5) |
| 5199 | result = ddf.mask(cond=dd_cond, other=5) |
| 5200 | assert_eq(expected, result) |
| 5201 | |
| 5202 | expected = df.where(cond=cond, other=5) |
| 5203 | result = ddf.where(cond=dd_cond, other=5) |
| 5204 | assert_eq(expected, result) |
| 5205 | |
| 5206 | |
| 5207 | def test_mask_where_callable(): |