MCPcopy Create free account
hub / github.com/dask/dask / test_mask_where_array_like

Function test_mask_where_array_like

dask/dataframe/tests/test_dataframe.py:5204–5225  ·  view source on GitHub ↗

DataFrame.mask fails for single-row partitions https://github.com/dask/dask/issues/9848

(df, cond)

Source from the content-addressed store, hash-verified

5202 ],
5203)
5204def 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
5228def test_mask_where_callable():

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
maskMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected