Skip to content

Commit

Permalink
Create benchmark for groupby (#5772)
Browse files Browse the repository at this point in the history
* Create groupby.py

* Update groupby.py

* Update groupby.py

* Update asv_bench/benchmarks/groupby.py

Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
  • Loading branch information
Illviljan and dcherian authored Sep 20, 2021
1 parent a1635d3 commit 7a65d59
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions asv_bench/benchmarks/groupby.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import numpy as np

import xarray as xr

from . import parameterized, requires_dask


class GroupBy:
def setup(self, *args, **kwargs):
self.ds = xr.Dataset(
{
"a": xr.DataArray(np.r_[np.arange(500.0), np.arange(500.0)]),
"b": xr.DataArray(np.arange(1000.0)),
}
)

@parameterized(["method"], [("sum", "mean")])
def time_agg(self, method):
return getattr(self.ds.groupby("a"), method)()


class GroupByDask(GroupBy):
def setup(self, *args, **kwargs):
requires_dask()
super().setup(**kwargs)
self.ds = self.ds.chunk({"dim_0": 50})


class GroupByDataFrame(GroupBy):
def setup(self, *args, **kwargs):
super().setup(**kwargs)
self.ds = self.ds.to_dataframe()


class GroupByDaskDataFrame(GroupBy):
def setup(self, *args, **kwargs):
requires_dask()
super().setup(**kwargs)
self.ds = self.ds.chunk({"dim_0": 50}).to_dataframe()

0 comments on commit 7a65d59

Please sign in to comment.