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

Method setup

asv_bench/benchmarks/indexing.py:121–139  ·  view source on GitHub ↗
(self, index, index_structure)

Source from the content-addressed store, hash-verified

119 param_names = ["index_dtype", "index_structure"]
120
121 def setup(self, index, index_structure):
122 N = 10**6
123 if index == "string":
124 index = Index([f"i-{i}" for i in range(N)], dtype=object)
125 elif index == "datetime":
126 index = date_range("1900", periods=N, freq="s")
127 elif index == "period":
128 index = period_range("1900", periods=N, freq="s")
129 index = index.sort_values()
130 assert index.is_unique and index.is_monotonic_increasing
131 if index_structure == "nonunique_monotonic_inc":
132 index = index.insert(item=index[2], loc=2)[:-1]
133 elif index_structure == "non_monotonic":
134 index = index[::2].append(index[1::2])
135 assert len(index) == N
136 self.s = Series(np.random.rand(N), index=index)
137 self.lbl = index[80000]
138 # warm up index mapping
139 self.s[self.lbl]
140
141 def time_getitem_label_slice(self, index, index_structure):
142 self.s[: self.lbl]

Callers

nothing calls this directly

Calls 7

sort_valuesMethod · 0.95
insertMethod · 0.95
IndexClass · 0.90
date_rangeFunction · 0.90
period_rangeFunction · 0.90
SeriesClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected