-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: Speed up DatetimeConverter by using Matplotlib's epoch2num when possible... #6650
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
Changes from 2 commits
1c65b96
dc95c4c
35f1dea
64d9e92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,3 +269,15 @@ def date_range(start=None, end=None, periods=None, freq=None): | |
dataframe_resample_max_numpy = \ | ||
Benchmark("df.resample('1s', how=np.max)", setup) | ||
|
||
|
||
#---------------------------------------------------------------------- | ||
# DatetimeConverter | ||
|
||
setup = common_setup + """ | ||
from pandas.tseries.converter import DatetimeConverter | ||
""" | ||
|
||
datetimeindex_converter = \ | ||
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. you need to define 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. Just to be sure, 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. sorry....you are right..ok then |
||
Benchmark('DatetimeConverter.convert(rng, None, None)', | ||
setup, start_date=datetime(2013, 1, 1)) | ||
|
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.
This ensures that the faster epoch2num variant is only used when appropriate (i.e., type(dt) = datetime64[ns]).
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.
this should test
(np.ndarray,Series)
.do
dt.view('i8')
instead of astyping (faster)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.
dt.view results in an AttributeError... can't figure out why.
dt.values.view('i8') instead works as expected, but I'd assume that also dt.view('i8') should work.
Edit: also dt.asi8 works. That seems to be the cleanest way perhaps.
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.
that's fine