diff --git a/asv_bench/benchmarks/indexing.py b/asv_bench/benchmarks/indexing.py index b9e565da2dbb2..d5f165084505f 100644 --- a/asv_bench/benchmarks/indexing.py +++ b/asv_bench/benchmarks/indexing.py @@ -290,20 +290,26 @@ def setup(self): self.dti = dti self.dti2 = dti2 - index = np.random.choice(dti, 10000, replace=True) - df = DataFrame(index=index, data={"a": 1}) - df_sort = df.sort_index() - self.df = df - self.df_sort = df_sort - def time_get_indexer_mismatched_tz(self): # reached via e.g. # ser = Series(range(len(dti)), index=dti) # ser[dti2] self.dti.get_indexer(self.dti2) + +class SortedAndUnsortedDatetimeIndexLoc: + def setup(self): + dti = date_range("2016-01-01", periods=10000, tz="US/Pacific") + index = np.array(dti) + + unsorted_index = index.copy() + unsorted_index[10] = unsorted_index[20] + + self.df_unsorted = DataFrame(index=unsorted_index, data={"a": 1}) + self.df_sort = DataFrame(index=index, data={"a": 1}) + def time_loc_unsorted(self): - self.df.loc["2016-6-11"] + self.df_unsorted.loc["2016-6-11"] def time_loc_sorted(self): self.df_sort.loc["2016-6-11"]