DataFrame.mask fails for single-row partitions https://github.com/dask/dask/issues/9848
(df, cond)
| 5163 | ], |
| 5164 | ) |
| 5165 | def test_mask_where_array_like(df, cond): |
| 5166 | """DataFrame.mask fails for single-row partitions |
| 5167 | https://github.com/dask/dask/issues/9848 |
| 5168 | """ |
| 5169 | ddf = dd.from_pandas(df, npartitions=2) |
| 5170 | |
| 5171 | # ensure raises when list is provided |
| 5172 | with pytest.raises(ValueError, match="can be aligned|shape"): |
| 5173 | ddf.mask(cond=cond, other=5) |
| 5174 | |
| 5175 | with pytest.raises(ValueError, match="can be aligned|shape"): |
| 5176 | ddf.where(cond=cond, other=5) |
| 5177 | |
| 5178 | # but works when DataFrame is provided, with matching index |
| 5179 | dd_cond = pd.DataFrame(cond, index=df.index, columns=df.columns) |
| 5180 | expected = df.mask(cond=cond, other=5) |
| 5181 | result = ddf.mask(cond=dd_cond, other=5) |
| 5182 | assert_eq(expected, result) |
| 5183 | |
| 5184 | expected = df.where(cond=cond, other=5) |
| 5185 | result = ddf.where(cond=dd_cond, other=5) |
| 5186 | assert_eq(expected, result) |
| 5187 | |
| 5188 | |
| 5189 | def test_mask_where_callable(): |