Skip to content

Commit e30a3e4

Browse files
authored
pandas 2.2: fix test_dataframe_groupby_tasks (#8475)
1 parent 487b4ec commit e30a3e4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

distributed/tests/test_dask_collections.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,28 +189,29 @@ async def test_loc(c, s, a, b):
189189

190190
@ignore_single_machine_warning
191191
def test_dataframe_groupby_tasks(client):
192+
INCLUDE_GROUPS = {"include_groups": False} if PANDAS_GE_220 else {}
192193
df = make_time_dataframe()
193194

194195
df["A"] = df.A // 0.1
195196
df["B"] = df.B // 0.1
196197
ddf = dd.from_pandas(df, npartitions=10)
197198

198199
for ind in [lambda x: "A", lambda x: x.A]:
199-
a = df.groupby(ind(df)).apply(len)
200-
b = ddf.groupby(ind(ddf)).apply(len, meta=(None, int))
200+
a = df.groupby(ind(df)).apply(len, **INCLUDE_GROUPS)
201+
b = ddf.groupby(ind(ddf)).apply(len, meta=(None, int), **INCLUDE_GROUPS)
201202
assert_equal(a, b.compute().sort_index())
202203
assert not any("partd" in k[0] for k in b.dask)
203204

204-
a = df.groupby(ind(df)).B.apply(len)
205-
b = ddf.groupby(ind(ddf)).B.apply(len, meta=("B", int))
205+
a = df.groupby(ind(df)).B.apply(len, **INCLUDE_GROUPS)
206+
b = ddf.groupby(ind(ddf)).B.apply(len, meta=("B", int), **INCLUDE_GROUPS)
206207
assert_equal(a, b.compute().sort_index())
207208
assert not any("partd" in k[0] for k in b.dask)
208209

209210
with pytest.raises((NotImplementedError, ValueError)):
210-
ddf.groupby(ddf[["A", "B"]]).apply(len, meta=int)
211+
ddf.groupby(ddf[["A", "B"]]).apply(len, meta=int, **INCLUDE_GROUPS)
211212

212-
a = df.groupby(["A", "B"]).apply(len)
213-
b = ddf.groupby(["A", "B"]).apply(len, meta=(None, int))
213+
a = df.groupby(["A", "B"]).apply(len, **INCLUDE_GROUPS)
214+
b = ddf.groupby(["A", "B"]).apply(len, meta=(None, int), **INCLUDE_GROUPS)
214215

215216
assert_equal(a, b.compute().sort_index())
216217

0 commit comments

Comments
 (0)