Skip to content

Benchmark for indexing with .loc for sorted/unsorted DatetimeIndex #46193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions asv_bench/benchmarks/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,24 @@ def setup(self):
self.dti = dti
self.dti2 = dti2

index = np.random.choice(dti, 10000, replace=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this a new class benchmark and make this deterministic (i.e. no random)

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)

def time_loc_unsorted(self):
self.df.loc["2016-6-11"]

def time_loc_sorted(self):
self.df_sort.loc["2016-6-11"]


class CategoricalIndexIndexing:

Expand Down