Skip to content
Next Next commit
ASV: Add benchmark for DataFrame.Update
  • Loading branch information
aureliobarbosa committed Apr 12, 2024
commit a13ed9fb1fdf858e58dd26da8d2e762600c95b1f
22 changes: 22 additions & 0 deletions asv_bench/benchmarks/frame_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,4 +862,26 @@ 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=(1000, 10)))

idx = rng.choice(range(1000), size=1000, replace=False)
self.df_random = DataFrame(self.df, index=idx)

idx = rng.choice(range(1000), size=100, replace=False)
cols = rng.choice(range(10), size=2, replace=False)
self.df_sample = DataFrame(rng.uniform(size=(100, 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