MCPcopy
hub / github.com/pandas-dev/pandas / setup

Method setup

asv_bench/benchmarks/join_merge.py:448–489  ·  view source on GitHub ↗
(self, direction, tolerance)

Source from the content-addressed store, hash-verified

446 param_names = ["direction", "tolerance"]
447
448 def setup(self, direction, tolerance):
449 one_count = 200000
450 two_count = 1000000
451
452 df1 = DataFrame(
453 {
454 "time": np.random.randint(0, one_count / 20, one_count),
455 "key": np.random.choice(list(string.ascii_uppercase), one_count),
456 "key2": np.random.randint(0, 25, one_count),
457 "value1": np.random.randn(one_count),
458 }
459 )
460 df2 = DataFrame(
461 {
462 "time": np.random.randint(0, two_count / 20, two_count),
463 "key": np.random.choice(list(string.ascii_uppercase), two_count),
464 "key2": np.random.randint(0, 25, two_count),
465 "value2": np.random.randn(two_count),
466 }
467 )
468
469 df1 = df1.sort_values("time")
470 df2 = df2.sort_values("time")
471
472 df1["time32"] = np.int32(df1.time)
473 df2["time32"] = np.int32(df2.time)
474
475 df1["timeu64"] = np.uint64(df1.time)
476 df2["timeu64"] = np.uint64(df2.time)
477
478 self.df1a = df1[["time", "value1"]]
479 self.df2a = df2[["time", "value2"]]
480 self.df1b = df1[["time", "key", "value1"]]
481 self.df2b = df2[["time", "key", "value2"]]
482 self.df1c = df1[["time", "key2", "value1"]]
483 self.df2c = df2[["time", "key2", "value2"]]
484 self.df1d = df1[["time32", "value1"]]
485 self.df2d = df2[["time32", "value2"]]
486 self.df1e = df1[["time", "key", "key2", "value1"]]
487 self.df2e = df2[["time", "key", "key2", "value2"]]
488 self.df1f = df1[["timeu64", "value1"]]
489 self.df2f = df2[["timeu64", "value2"]]
490
491 def time_on_int(self, direction, tolerance):
492 merge_asof(

Callers

nothing calls this directly

Calls 2

sort_valuesMethod · 0.95
DataFrameClass · 0.90

Tested by

no test coverage detected