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

Function test_transform_getitem_works

dask/dataframe/tests/test_dataframe.py:5152–5164  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

5150
5151@pytest.mark.parametrize("func", ["max", "sum"])
5152def test_transform_getitem_works(func):
5153 df = pd.DataFrame({"ints": [1, 2, 3], "grouper": [0, 1, 0]})
5154
5155 ddf = dd.from_pandas(df, npartitions=2)
5156
5157 # what happens here is not exactly a transform, but a reduction
5158 # the result of which is broadcasted back to the original shape.
5159 # Broadcasting an aggregation in this manner is very performant in pandas
5160 meta = df.groupby("grouper").transform(func)
5161 df["new"] = df.groupby("grouper").transform(func)["ints"]
5162 ddf["new"] = ddf.groupby("grouper").transform(func, meta=meta)["ints"]
5163
5164 assert_eq(df, ddf)
5165
5166
5167@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

groupbyMethod · 0.95
assert_eqFunction · 0.90
transformMethod · 0.80
groupbyMethod · 0.45

Tested by

no test coverage detected