| 5150 | |
| 5151 | @pytest.mark.parametrize("func", ["max", "sum"]) |
| 5152 | def 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( |