Repository: modin-project/modin

Issue:
[ASV] port stack, unstack, replace and  groups benchmarks from pandas github
Have to add ASV benchmarks related which does the following actions
1) perform stack and unstack on dataframe.
2) Replace function on a dataframe.
3) Get groups returned by groupby.


Discussion:

Resolving patch:
diff --git a/asv_bench/benchmarks/benchmarks.py b/asv_bench/benchmarks/benchmarks.py
--- a/asv_bench/benchmarks/benchmarks.py
+++ b/asv_bench/benchmarks/benchmarks.py
@@ -1113,4 +1113,71 @@ def time_remove_categories(self, shape):
         execute(self.ts.cat.remove_categories(self.ts.cat.categories[::2]))
 
 
+class BaseReshape:
+    def setup(self, shape):
+        rows, cols = shape
+        k = 10
+        arrays = [
+            np.arange(rows // k).repeat(k),
+            np.roll(np.tile(np.arange(rows // k), k), 25),
+        ]
+        index = IMPL.MultiIndex.from_arrays(arrays)
+        self.df = IMPL.DataFrame(np.random.randn(rows, cols), index=index)
+        execute(self.df)
+
+
+class TimeStack(BaseReshape):
+    params = [get_benchmark_shapes("TimeStack")]
+    param_names = ["shape"]
+
+    def setup(self, shape):
+        super().setup(shape)
+        self.udf = self.df.unstack(1)
+        execute(self.udf)
+
+    def time_stack(self, shape):
+        execute(self.udf.stack())
+
+
+class TimeUnstack(BaseReshape):
+    params = [get_benchmark_shapes("TimeUnstack")]
+    param_names = ["shape"]
+
+    def time_unstack(self, shape):
+        execute(self.df.unstack(1))
+
+
+class TimeReplace:
+
+    params = [get_benchmark_shapes("TimeReplace")]
+    param_names = ["shape"]
+
+    def setup(self, shape):
+        rows, cols = shape
+        self.to_replace = {i: getattr(IMPL, "Timestamp")(i) for i in range(rows)}
+        self.df = IMPL.DataFrame(np.random.randint(rows, size=(rows, cols)))
+        execute(self.df)
+
+    def time_replace(self, shape):
+        execute(self.df.replace(self.to_replace))
+
+
+class TimeGroups:
+
+    params = [get_benchmark_shapes("TimeGroups")]
+    param_names = ["shape"]
+
+    def setup(self, shape):
+        self.series = IMPL.Series(np.random.randint(0, 100, size=shape[0]))
+        execute(self.series)
+
+    # returns a pretty dict thus not calling execute
+    def time_series_groups(self, shape):
+        self.series.groupby(self.series).groups
+
+    # returns a dict thus not calling execute
+    def time_series_indices(self, shape):
+        self.series.groupby(self.series).indices
+
+
 from .utils import setup  # noqa: E402, F401
diff --git a/asv_bench/benchmarks/utils/data_shapes.py b/asv_bench/benchmarks/utils/data_shapes.py
--- a/asv_bench/benchmarks/utils/data_shapes.py
+++ b/asv_bench/benchmarks/utils/data_shapes.py
@@ -101,6 +101,8 @@
             "TimeReindexMethod",
             "TimeFillnaMethodDataframe",
             "TimeDropDuplicatesDataframe",
+            "TimeStack",
+            "TimeUnstack",
             # IO benchmarks
             "TimeReadCsvSkiprows",
             "TimeReadCsvTrueFalseValues",
@@ -128,6 +130,7 @@
         [
             # Pandas storage format benchmarks
             "TimeFillnaSeries",
+            "TimeGroups",
             "TimeIndexingNumericSeries",
             "TimeFillnaMethodSeries",
             "TimeDatetimeAccessor",
@@ -183,6 +186,9 @@
 DEFAULT_CONFIG["TimeJoinStringIndex"] = (
     [[100_000, 64]] if ASV_DATASET_SIZE == "big" else [[1_000, 4]]
 )
+DEFAULT_CONFIG["TimeReplace"] = (
+    [[10_000, 2]] if ASV_DATASET_SIZE == "big" else [[1_000, 2]]
+)
 for config in (_DEFAULT_CONFIG_T, _DEFAULT_HDK_CONFIG_T):
     for _shape, _names in config:
         DEFAULT_CONFIG.update({_name: _shape for _name in _names})


Test patch: