-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: to_datetime internals #21702
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
CLN: to_datetime internals #21702
Conversation
Hello @mroeschke! Thanks for updating the PR.
Comment last updated on July 03, 2018 at 05:24 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #21702 +/- ##
==========================================
+ Coverage 91.9% 91.91% +<.01%
==========================================
Files 158 158
Lines 49690 49695 +5
==========================================
+ Hits 45670 45675 +5
Misses 4020 4020
Continue to review full report at Codecov.
|
lgtm. can you do a perf check to make sure nothing changed (as the caching logic was lightly touched here) |
@@ -38,7 +39,7 @@ def _guess_datetime_format_for_array(arr, **kwargs): | |||
return _guess_datetime_format(arr[non_nan_elements[0]], **kwargs) | |||
|
|||
|
|||
def _maybe_cache(arg, format, cache, tz, convert_listlike): |
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.
The tz here was not used?
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.
tz was passed into the convert_listlike
function further down, but now I am embedding it into convert_listlike
with functools.partial
in to_datetime
raise e | ||
|
||
|
||
def _adjust_to_origin(arg, origin, unit): |
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.
+1 for separating this out
pandas/core/tools/datetimes.py
Outdated
passed unit from to_datetime, must be 'D' | ||
Returns | ||
------- | ||
ndarray of adjusted dates |
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.
Is it necessarily an ndarray
? Couldn't it be a Timestamp
?
need newline before Returns
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 catch, yeah this can be a scalar value. Will fix that tonight.
My asv setup is still a little broken, but here's a benchmark showing no performance hit (with cache)
|
thanks @mroeschke happily take refactorings to clean up things / make more readable |
git diff upstream/master -u -- "*.py" | flake8 --diff
The internals of
to_datetime
is getting a bit unwieldy, so split out the_convert_listlike
logic and origin shifting logic to_convert_listlike_datetime
andadjust_to_origin
methods respectively outside ofto_datetime
. The logic was not changed.