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

Function test_transform_getitem_works

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

Source from the content-addressed store, hash-verified

5171
5172@pytest.mark.parametrize("func", ["max", "sum"])
5173def test_transform_getitem_works(func):
5174 df = pd.DataFrame({"ints": [1, 2, 3], "grouper": [0, 1, 0]})
5175
5176 ddf = dd.from_pandas(df, npartitions=2)
5177
5178 # what happens here is not exactly a transform, but a reduction
5179 # the result of which is broadcasted back to the original shape.
5180 # Broadcasting an aggregation in this manner is very performant in pandas
5181 meta = df.groupby("grouper").transform(func)
5182 df["new"] = df.groupby("grouper").transform(func)["ints"]
5183 ddf["new"] = ddf.groupby("grouper").transform(func, meta=meta)["ints"]
5184
5185 assert_eq(df, ddf)
5186
5187
5188@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