Skip to content

Commit a6869e8

Browse files
Fix a groupby pytest related to numeric_only (#13496)
This PR fixes a groupby pytest by performing a special version based handling, we will need this handling because of no support for numeric_only in groupby.agg yet.
1 parent 139e32d commit a6869e8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

python/cudf/cudf/tests/test_groupby.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -1876,14 +1876,19 @@ def test_groupby_list_columns_excluded():
18761876
)
18771877
gdf = cudf.from_pandas(pdf)
18781878

1879-
# cudf does not yet support numeric_only, so our default is False, but
1880-
# pandas defaults to inferring and throws a warning about it, so we need to
1881-
# catch that. pandas future behavior will match ours by default (at which
1882-
# point supporting numeric_only=True will be the open feature request).
1883-
with pytest.warns(FutureWarning):
1884-
pandas_result = pdf.groupby("a").mean()
1885-
with pytest.warns(FutureWarning):
1886-
pandas_agg_result = pdf.groupby("a").agg("mean")
1879+
if PANDAS_GE_200:
1880+
pandas_result = pdf.groupby("a").mean(numeric_only=True)
1881+
pandas_agg_result = pdf.groupby("a").agg("mean", numeric_only=True)
1882+
else:
1883+
# cudf does not yet support numeric_only, so our default is False, but
1884+
# pandas defaults to inferring and throws a warning about it, so
1885+
# we need to catch that. pandas future behavior will match ours
1886+
# by default (at which point supporting numeric_only=True will
1887+
# be the open feature request).
1888+
with pytest.warns(FutureWarning):
1889+
pandas_result = pdf.groupby("a").mean()
1890+
with pytest.warns(FutureWarning):
1891+
pandas_agg_result = pdf.groupby("a").agg("mean")
18871892

18881893
assert_groupby_results_equal(
18891894
pandas_result, gdf.groupby("a").mean(), check_dtype=False

0 commit comments

Comments
 (0)