Improve DatetimeIndex.time performance by jamestran201 · Pull Request #18461 · pandas-dev/pandas (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation10 Commits3 Checks0 Files changed
Conversation
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
[ Show hidden characters]({{ revealButtonHref }})
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 toints_to_pydatetime()
or not.
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") |
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 |
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)
@jreback @bashtage sorry for the late reply. The asv is:
before after ratio
[e6eac0b3] [c274e8d5]
- 9.17±0.2ms 1.17±0.02ms 0.13 timeseries.DatetimeIndex.time_dti_time
should any other changes be made in addition to changing the assertion to an else block?
This was referenced
May 31, 2018