| 5171 | |
| 5172 | @pytest.mark.parametrize("func", ["max", "sum"]) |
| 5173 | def 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( |