From 888b6bc1bb3fdf203dda64e50336db4eb9b1e778 Mon Sep 17 00:00:00 2001 From: Marco Barbosa Date: Mon, 15 Apr 2024 18:16:32 -0300 Subject: [PATCH] ASV: benchmark for DataFrame.Update (#58228) --- asv_bench/benchmarks/frame_methods.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/asv_bench/benchmarks/frame_methods.py b/asv_bench/benchmarks/frame_methods.py index ce31d63f0b70f..6a2ab24df26fe 100644 --- a/asv_bench/benchmarks/frame_methods.py +++ b/asv_bench/benchmarks/frame_methods.py @@ -862,4 +862,28 @@ def time_last_valid_index(self, dtype): self.df.last_valid_index() +class Update: + def setup(self): + rng = np.random.default_rng() + self.df = DataFrame(rng.uniform(size=(1_000_000, 10))) + + idx = rng.choice(range(1_000_000), size=1_000_000, replace=False) + self.df_random = DataFrame(self.df, index=idx) + + idx = rng.choice(range(1_000_000), size=100_000, replace=False) + cols = rng.choice(range(10), size=2, replace=False) + self.df_sample = DataFrame( + rng.uniform(size=(100_000, 2)), index=idx, columns=cols + ) + + def time_to_update_big_frame_small_arg(self): + self.df.update(self.df_sample) + + def time_to_update_random_indices(self): + self.df_random.update(self.df_sample) + + def time_to_update_small_frame_big_arg(self): + self.df_sample.update(self.df) + + from .pandas_vb_common import setup # noqa: F401 isort:skip