-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BENCH : Added benchmark for indexing with .loc for sorted/unsorted DatetimeIndex #43931
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
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5f28727
TST : Added benchmark for indexing with .loc
sonalprabhu a5022ad
Removed whitespace
sonalprabhu d7f5f51
Removed pd prefix
sonalprabhu b1a0449
Fixes from pre-commit [automated commit]
sonalprabhu ea481c2
Adhered to naming conventions and removed unnecessary variables
sonalprabhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,15 +247,27 @@ class DatetimeIndexIndexing: | |
def setup(self): | ||
dti = date_range("2016-01-01", periods=10000, tz="US/Pacific") | ||
dti2 = dti.tz_convert("UTC") | ||
dates = date_range("2011-1-1", periods=500000, freq="min") | ||
index = np.random.choice(dates, 500000, replace=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep the naming consistent, maybe call this something like |
||
df = DataFrame(index=index, data={"a": 1}) | ||
df_sorted = df.sort_index() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you inline |
||
self.dti = dti | ||
self.dti2 = dti2 | ||
self.df = df | ||
self.df_sorted = df_sorted | ||
|
||
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["2011-6-11"] | ||
|
||
def time_loc_sorted(self): | ||
self.df_sorted.loc["2011-6-11"] | ||
|
||
|
||
class CategoricalIndexIndexing: | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To simplify/speed up construction, can we use the already constructed
dti
on L248?