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

Function test_aggregate__single_element_groups

dask/dataframe/tests/test_groupby.py:899–921  ·  view source on GitHub ↗
(agg_func)

Source from the content-addressed store, hash-verified

897
898
899def test_aggregate__single_element_groups(agg_func):
900 spec = agg_func
901
902 # nunique/cov is not supported in specs
903 if spec in ("nunique", "cov", "corr"):
904 return
905
906 pdf = pd.DataFrame(
907 {"a": [1, 1, 3, 3], "b": [4, 4, 16, 16], "c": [1, 1, 4, 4], "d": [1, 1, 3, 3]},
908 columns=["c", "b", "a", "d"],
909 )
910 ddf = dd.from_pandas(pdf, npartitions=3)
911
912 expected = pdf.groupby(["a", "d"]).agg(spec)
913
914 # NOTE: for std the result is not recast to the original dtype
915 if spec in {"mean", "var"}:
916 expected = expected.astype(float)
917
918 shuffle_method = (
919 {"shuffle_method": "tasks", "split_out": 2} if agg_func == "median" else {}
920 )
921 assert_eq(expected, ddf.groupby(["a", "d"]).agg(spec, **shuffle_method))
922
923
924def test_aggregate_build_agg_args__reuse_of_intermediates():

Callers

nothing calls this directly

Calls 5

groupbyMethod · 0.95
assert_eqFunction · 0.90
aggMethod · 0.45
astypeMethod · 0.45
groupbyMethod · 0.45

Tested by

no test coverage detected