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:5183–5204  ·  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

5181 ],
5182)
5183def 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
5207def 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