-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Implement roll_monthday, simplify SemiMonthOffset #18762
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 1 commit
6100c3f
aac0832
c5bc5b2
15b7916
cb07e88
eb5e72f
ec3b24d
c6f025b
f5694de
2566bf5
0838271
a649238
425d3b4
71f138d
091acc2
365cdb8
9993a91
5d773a5
a5d9dee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -824,7 +824,23 @@ cpdef int get_day_of_month(datetime other, day_opt) except? -1: | |
raise ValueError(day_opt) | ||
|
||
|
||
cpdef int roll_monthday(int n, other, compare): | ||
cpdef int roll_monthday(other, int n, compare): | ||
""" | ||
Possibly increment or decrement the number of periods to shift | ||
based on rollforward/rollbackward conventions. | ||
|
||
Parameters | ||
---------- | ||
other : datetime or Timestamp | ||
n : number of periods to increment, before adjusting for rolling | ||
day_opt : 'start', 'end', 'business_start', 'business_end' | ||
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. this does not match the signature |
||
The convention to use in finding the day in a given month against | ||
which to compare for rollforward/rollbackward decisions. | ||
|
||
Returns | ||
------- | ||
n : int number of periods to increment | ||
""" | ||
# Either `other` and `compare` are _both_ datetimes or they are both | ||
# integers for days in the same month. | ||
|
||
|
@@ -836,8 +852,25 @@ cpdef int roll_monthday(int n, other, compare): | |
return n | ||
|
||
|
||
cpdef inline int roll_qtrday(other, n, month, day_opt='start', | ||
int modby=3) except? -1: | ||
cpdef int roll_qtrday(datetime other, int n, int month, day_opt='start', | ||
int modby=3) except? -1: | ||
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. make day_opt non-optional |
||
""" | ||
Possibly increment or decrement the number of periods to shift | ||
based on rollforward/rollbackward conventions. | ||
|
||
Parameters | ||
---------- | ||
other : datetime or Timestamp | ||
n : number of periods to increment, before adjusting for rolling | ||
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. does not match the signature |
||
month : reference month giving the first month of the year | ||
day_opt : 'start', 'end', 'business_start', 'business_end' | ||
The convention to use in finding the day in a given month against | ||
which to compare for rollforward/rollbackward decisions. | ||
|
||
Returns | ||
------- | ||
n : int number of periods to increment | ||
""" | ||
# TODO: type `other` as datetime-or-pandas_datetimestruct? | ||
# TODO: Merge this with roll_yearday by setting modby=12 there? | ||
# code de-duplication versus perf hit? | ||
|
@@ -869,6 +902,7 @@ cpdef int roll_yearday(other, n, month, day_opt='start') except? -1: | |
---------- | ||
other : datetime or Timestamp | ||
n : number of periods to increment, before adjusting for rolling | ||
month : reference month giving the first month of the year | ||
day_opt : 'start', 'end' | ||
'start': returns 1 | ||
'end': returns last day of the month | ||
|
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.
needs typing