-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create benchmark for groupby (#5772)
* 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
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |