-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
implement non-controversial cleanup portions of #18762 #18959
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
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -523,11 +523,9 @@ def shift_quarters(int64_t[:] dtindex, int quarters, | |
n = quarters | ||
|
||
months_since = (dts.month - q1start_month) % modby | ||
compare_month = dts.month - months_since | ||
compare_month = compare_month or 12 | ||
# compare_day is only relevant for comparison in the case | ||
# where months_since == 0. | ||
compare_day = get_firstbday(dts.year, compare_month) | ||
compare_day = get_firstbday(dts.year, dts.month) | ||
|
||
if n <= 0 and (months_since != 0 or | ||
(months_since == 0 and dts.day > compare_day)): | ||
|
@@ -556,11 +554,9 @@ def shift_quarters(int64_t[:] dtindex, int quarters, | |
n = quarters | ||
|
||
months_since = (dts.month - q1start_month) % modby | ||
compare_month = dts.month - months_since | ||
compare_month = compare_month or 12 | ||
# compare_day is only relevant for comparison in the case | ||
# where months_since == 0. | ||
compare_day = get_lastbday(dts.year, compare_month) | ||
compare_day = get_lastbday(dts.year, dts.month) | ||
|
||
if n <= 0 and (months_since != 0 or | ||
(months_since == 0 and dts.day > compare_day)): | ||
|
@@ -587,15 +583,17 @@ def shift_quarters(int64_t[:] dtindex, int quarters, | |
|
||
@cython.wraparound(False) | ||
@cython.boundscheck(False) | ||
def shift_months(int64_t[:] dtindex, int months, object day=None): | ||
def shift_months(int64_t[:] dtindex, int months, object day): | ||
""" | ||
Given an int64-based datetime index, shift all elements | ||
specified number of months using DateOffset semantics | ||
|
||
day: {None, 'start', 'end'} | ||
day: {None, 'start', 'end', 'business_start', 'business_end'} | ||
* None: day of month | ||
* 'start' 1st day of month | ||
* 'end' last day of month | ||
* 'business_start' first business day of month | ||
* 'business_end' last business day of month | ||
""" | ||
cdef: | ||
Py_ssize_t i | ||
|
@@ -721,7 +719,7 @@ def shift_months(int64_t[:] dtindex, int months, object day=None): | |
return np.asarray(out) | ||
|
||
|
||
cpdef datetime shift_month(datetime stamp, int months, object day_opt=None): | ||
cpdef datetime shift_month(datetime stamp, int months, object day_opt): | ||
""" | ||
Given a datetime (or Timestamp) `stamp`, an integer `months` and an | ||
option `day_opt`, return a new datetimelike that many months later, | ||
|
@@ -827,7 +825,8 @@ cpdef int get_day_of_month(datetime other, day_opt) except? -1: | |
raise ValueError(day_opt) | ||
|
||
|
||
cpdef int roll_yearday(other, n, month, day_opt='start') except? -1: | ||
cpdef int roll_yearday(datetime other, int n, int month, | ||
object day_opt) except? -1: | ||
""" | ||
Possibly increment or decrement the number of periods to shift | ||
based on rollforward/rollbackward conventions. | ||
|
@@ -836,17 +835,20 @@ 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 | ||
day_opt : 'start', 'end' | ||
'start': returns 1 | ||
'end': returns last day of the month | ||
month : reference month giving the first month of the year | ||
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. I would make this a required parameter and pass it. its more obvious. 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. Sounds good. Just pushed. |
||
day_opt : 'start', 'end', 'business_start', 'business_end' | ||
'start': compare with 1 | ||
'end': compare with last day of the month | ||
'business_start': compare with first business day of the month | ||
'business_end': compare with last business day of the month | ||
|
||
Returns | ||
------- | ||
n : int number of periods to increment | ||
|
||
Notes | ||
----- | ||
* Mirrors `roll_check` in tslib.shift_months | ||
* Mirrors `roll_check` in shift_months | ||
|
||
Examples | ||
------- | ||
|
@@ -888,7 +890,7 @@ cpdef int roll_yearday(other, n, month, day_opt='start') except? -1: | |
other.day < get_day_of_month(other, | ||
day_opt)): | ||
n -= 1 | ||
elif n <= 0: | ||
else: | ||
if other.month > month or (other.month == month and | ||
other.day > get_day_of_month(other, | ||
day_opt)): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
remove the None as a valid argument or is it? also need to fix the code
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.
None is valid.