-
Notifications
You must be signed in to change notification settings - Fork 358
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
Implement DatetimeIndex.indexer_at_time() #2109
Conversation
xinrong-meng
commented
Mar 18, 2021
•
edited by ueshin
Loading
edited by ueshin
@@ -634,6 +636,49 @@ def strftime(self, date_format: str) -> Index: | |||
""" | |||
return Index(self.to_series().dt.strftime(date_format)) | |||
|
|||
def indexer_at_time(self, time: Union[datetime.time, str], asof: bool = False) -> Index: |
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.
asof
is not implemented in pandas yet, so there is not docstring for it.
https://github.com/pandas-dev/pandas/blob/v1.2.3/pandas/core/indexes/datetimes.py#L828-L865
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.
Shall we check it before we call apply_batch
; otherwise the error will be messy.
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.
Good idea!
Codecov Report
@@ Coverage Diff @@
## master #2109 +/- ##
==========================================
- Coverage 95.21% 89.90% -5.32%
==========================================
Files 60 60
Lines 13460 13339 -121
==========================================
- Hits 12816 11992 -824
- Misses 644 1347 +703
Continue to review full report at Codecov.
|
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.
Otherwise, LGTM.
Could you also fix the conflicts?
@@ -634,6 +636,49 @@ def strftime(self, date_format: str) -> Index: | |||
""" | |||
return Index(self.to_series().dt.strftime(date_format)) | |||
|
|||
def indexer_at_time(self, time: Union[datetime.time, str], asof: bool = False) -> Index: |
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.
Shall we check it before we call apply_batch
; otherwise the error will be messy.
Examples | ||
-------- | ||
>>> kidx = ks.date_range("2000-01-01", periods=3, freq="T") | ||
>>> kidx # doctest: +NORMALIZE_WHITESPACE |
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.
nit: 2 spaces between kidx
and # doctest
.
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.
Updated.
1a12359
to
4b814dc
Compare
Thanks! merging. |