Skip to content

REF: re-use existing conversion functions #34625

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

Merged
merged 4 commits into from
Jun 8, 2020

Conversation

jbrockmendel
Copy link
Member

No description provided.

return npy_datetimestruct_to_datetime(unit, dts)


cdef NPY_DATETIMEUNIT get_unit(int freq) nogil:
Copy link
Member

Choose a reason for hiding this comment

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

This could alternately just be an enum right? OK as is just suggesting as possible easier solution

Copy link
Member Author

Choose a reason for hiding this comment

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

I think what you're suggesting is something like:

cdef enum FreqGroup:
    FR_MTH = NPY_DATETIMEUNIT.NPY_FR_M
    FR_DAY = NPY_DATETIMEUNIT.NPY_FR_D
    [...]

LMK if you have something else in mind.

The trouble with that is that we currently actually use the values for FR_FOO directly, and this would change those.

There are a bunch of near-duplicate enum-like codes floating around that i do want to de-duplicate. #34588 makes FreqGroup an enum, and after #34587 im hoping we can de-duplicate FreqGroup with Resolution.

@WillAyd
Copy link
Member

WillAyd commented Jun 7, 2020 via email

@WillAyd WillAyd added the Refactor Internal refactoring of code label Jun 7, 2020
@WillAyd WillAyd added this to the 1.1 milestone Jun 7, 2020
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.

small comment

return NPY_DATETIMEUNIT.NPY_FR_D
if freq == FR_HR:
return NPY_DATETIMEUNIT.NPY_FR_h
if freq == FR_MIN:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you do elif

Copy link
Member Author

Choose a reason for hiding this comment

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

updated+green

@jreback jreback merged commit 085d0dc into pandas-dev:master Jun 8, 2020
@jbrockmendel jbrockmendel deleted the ref-libperiod-reuse branch June 8, 2020 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants