Skip to content

Commit c8a0804

Browse files
ASV: reduce overall run time for GroupByMethods benchmarks (#44604)
1 parent d74cb77 commit c8a0804

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

asv_bench/benchmarks/groupby.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class GroupByMethods:
443443
"var",
444444
],
445445
["direct", "transformation"],
446-
[1, 2, 5, 10],
446+
[1, 5],
447447
]
448448

449449
def setup(self, dtype, method, application, ncols):
@@ -455,6 +455,7 @@ def setup(self, dtype, method, application, ncols):
455455
raise NotImplementedError
456456

457457
if application == "transformation" and method in [
458+
"describe",
458459
"head",
459460
"tail",
460461
"unique",
@@ -464,7 +465,12 @@ def setup(self, dtype, method, application, ncols):
464465
# DataFrameGroupBy doesn't have these methods
465466
raise NotImplementedError
466467

467-
ngroups = 1000
468+
if method == "describe":
469+
ngroups = 20
470+
elif method in ["mad", "skew"]:
471+
ngroups = 100
472+
else:
473+
ngroups = 1000
468474
size = ngroups * 2
469475
rng = np.arange(ngroups).reshape(-1, 1)
470476
rng = np.broadcast_to(rng, (len(rng), ncols))
@@ -491,9 +497,6 @@ def setup(self, dtype, method, application, ncols):
491497
cols = cols[0]
492498

493499
if application == "transformation":
494-
if method == "describe":
495-
raise NotImplementedError
496-
497500
self.as_group_method = lambda: df.groupby("key")[cols].transform(method)
498501
self.as_field_method = lambda: df.groupby(cols)["key"].transform(method)
499502
else:

0 commit comments

Comments
 (0)