Skip to content

Commit bdc2cd4

Browse files
ASV: add GroupBy.sum benchmark with timedelta and integer types (#55273)
add SumTimeDelta asv benchmark Co-authored-by: Willian Wang <git@willian.wang>
1 parent f9ade66 commit bdc2cd4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

asv_bench/benchmarks/groupby.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,23 @@ def time_groupby_sum_multiindex(self):
841841
self.df.groupby(level=[0, 1]).sum()
842842

843843

844+
class SumTimeDelta:
845+
# GH 20660
846+
def setup(self):
847+
N = 10**4
848+
self.df = DataFrame(
849+
np.random.randint(1000, 100000, (N, 100)),
850+
index=np.random.randint(200, size=(N,)),
851+
).astype("timedelta64[ns]")
852+
self.df_int = self.df.copy().astype("int64")
853+
854+
def time_groupby_sum_timedelta(self):
855+
self.df.groupby(lambda x: x).sum()
856+
857+
def time_groupby_sum_int(self):
858+
self.df_int.groupby(lambda x: x).sum()
859+
860+
844861
class Transform:
845862
def setup(self):
846863
n1 = 400

0 commit comments

Comments
 (0)