Skip to content

Commit b221a80

Browse files
author
Khor Chean Wei
authored
add benchmark (#46193)
1 parent 53b3dd5 commit b221a80

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

asv_bench/benchmarks/indexing.py

+12
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,24 @@ def setup(self):
290290
self.dti = dti
291291
self.dti2 = dti2
292292

293+
index = np.random.choice(dti, 10000, replace=True)
294+
df = DataFrame(index=index, data={"a": 1})
295+
df_sort = df.sort_index()
296+
self.df = df
297+
self.df_sort = df_sort
298+
293299
def time_get_indexer_mismatched_tz(self):
294300
# reached via e.g.
295301
# ser = Series(range(len(dti)), index=dti)
296302
# ser[dti2]
297303
self.dti.get_indexer(self.dti2)
298304

305+
def time_loc_unsorted(self):
306+
self.df.loc["2016-6-11"]
307+
308+
def time_loc_sorted(self):
309+
self.df_sort.loc["2016-6-11"]
310+
299311

300312
class CategoricalIndexIndexing:
301313

0 commit comments

Comments
 (0)