-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Improve DatetimeIndex.time performance #18461
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18461 +/- ##
==========================================
- Coverage 91.35% 91.31% -0.05%
==========================================
Files 163 163
Lines 49695 49695
==========================================
- Hits 45401 45380 -21
- Misses 4294 4315 +21
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18461 +/- ##
==========================================
- Coverage 91.35% 91.31% -0.05%
==========================================
Files 163 163
Lines 49695 49695
==========================================
- Hits 45401 45380 -21
- Misses 4294 4315 +21
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18461 +/- ##
==========================================
- Coverage 91.6% 91.56% -0.05%
==========================================
Files 153 153
Lines 51273 51273
==========================================
- Hits 46970 46947 -23
- Misses 4303 4326 +23
Continue to review full report at Codecov.
|
pandas/_libs/tslib.pyx
Outdated
If Timestamp, convert to pandas.Timestamp | ||
|
||
Returns | ||
------- | ||
result : array of dtype specified by box | ||
""" | ||
|
||
assert ((box == "datetime") or (box == "date") or (box == "timestamp")), \ | ||
"box must be one of 'datetime', 'date' or 'timestamp'" | ||
assert ((box == "datetime") or (box == "date") or (box == "timestamp") |
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.
Why not use box in ('datetime', 'date',...)? Seems unnecessarily C-like
@@ -125,6 +133,8 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, freq=None, | |||
if is_string_object(freq): | |||
from pandas.tseries.frequencies import to_offset | |||
freq = to_offset(freq) | |||
elif box == "time": | |||
func_create = create_time_from_ts | |||
elif box == "datetime": | |||
func_create = create_datetime_from_ts |
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.
alternatively, can remove the assert and make else the raise case
can you post the result of the asv as well (IOW how well does this do) |
can u rebase |
thanks @tmnhat2001 |
thanks |
xref #18058
tests added / passed
passes
git diff upstream/master -u -- "*.py" | flake8 --diff
whatsnew entry
Speed up DatetimeIndex.time in a similar way to DatetimeIndex.date. Not sure whether the timezone information should be passed to
ints_to_pydatetime()
or not.