-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
return npy_datetimestruct_to_datetime(unit, dts) | ||
|
||
|
||
cdef NPY_DATETIMEUNIT get_unit(int freq) nogil: |
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 could alternately just be an enum right? OK as is just suggesting as possible easier solution
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.
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.
Yep exactly. Makes sense for future plan
…Sent from my iPhone
On Jun 7, 2020, at 9:46 AM, jbrockmendel ***@***.***> wrote:
@jbrockmendel commented on this pull request.
In pandas/_libs/tslibs/period.pyx:
> return DtoB(dts, 0, unix_date)
- elif freq_group == FR_WK:
- return unix_date_to_week(unix_date, freq - FR_WK)
+ unit = get_unit(freq)
+ return npy_datetimestruct_to_datetime(unit, dts)
+
+
+cdef NPY_DATETIMEUNIT get_unit(int freq) nogil:
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.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
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.
small comment
pandas/_libs/tslibs/period.pyx
Outdated
return NPY_DATETIMEUNIT.NPY_FR_D | ||
if freq == FR_HR: | ||
return NPY_DATETIMEUNIT.NPY_FR_h | ||
if freq == FR_MIN: |
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.
can you do elif
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.
updated+green
No description provided.