Skip to content

Move time conversion funcs to tslibs.conversion #17708

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

Closed

Conversation

jbrockmendel
Copy link
Member

Eventually a bunch of _TSObject logic belongs in tslibs.conversion. To start off small, this just moves a few out-of-place functions from _libs.lib and _libs.index.

The changes that are not cut/paste:

In _to_i8: tslib._delta_to_nanoseconds(offset) became int(offset.total_seconds() * 1e9)
In array_to_timestamp and time64_to_datetime: for i from 0 <= i < n: became for i in range(n):

Right now the functions moved from lib are imported with a # noqa. If OK, I'll follow-up by updating the imports elsewhere.

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove all of these with 1 change as noted below

return gmtime(dt)


def array_to_timestamp(ndarray[object, ndim=1] arr):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is called anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look like it, no. But its def and not cdef, so conceivably used downstream. OK to remove?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ok to remove

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are ALL private modules (did that on purpose), so can move code around as long as we are internally consistent

return result


def time64_to_datetime(ndarray[int64_t, ndim=1] arr):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a simple call to pd.to_datetime

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used in io.pytables. OK to replace then remove?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think you can just replace that call in pytables

@jbrockmendel
Copy link
Member Author

Looks like to_timestamp func isnt used, besides which it is inconveniently named. OK to remove?

@jbrockmendel
Copy link
Member Author

and _to_i8 looks like it can be subsumed by tslib.pydt_to_i8

@jreback
Copy link
Contributor

jreback commented Sep 28, 2017

@jbrockmendel yep happy to delete code

@jreback jreback closed this Sep 28, 2017
@jbrockmendel jbrockmendel deleted the tslibs-conversion branch September 29, 2017 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants