-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
simplify CBMonth.apply to remove roll_monthday #19146
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
pandas/tseries/offsets.py
Outdated
return CustomBusinessDay(n=self.n, normalize=self.normalize, **kwds) | ||
cbday = CustomBusinessDay(n=self.n, normalize=False, **self.kwds) | ||
|
||
# Define default roll function to be called in apply method |
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.
why not simply define roll_func
(better name?) as a property (or function) or CBD?
pandas/tseries/offsets.py
Outdated
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end') | ||
_prefix = 'CBM' | ||
moff = MonthEnd(n=1, normalize=False) | ||
moff.roll_func = moff.rollforward |
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.
same, this is very odd to do, just make this a property
Codecov Report
@@ Coverage Diff @@
## master #19146 +/- ##
=========================================
Coverage ? 91.51%
=========================================
Files ? 148
Lines ? 48782
Branches ? 0
=========================================
Hits ? 44641
Misses ? 4141
Partials ? 0
Continue to review full report at Codecov.
|
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.
some more doc-strings, otherwise lgtm.
pandas/tseries/offsets.py
Outdated
_prefix = 'CBM' | ||
@cache_readonly | ||
def month_roll(self): | ||
if self._prefix.endswith('S'): |
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 add a comment to this and cbday_roll. I like the syntax, but a future reader won't get this immediately.
pandas/tseries/offsets.py
Outdated
def cbday_roll(self): | ||
cbday = CustomBusinessDay(n=self.n, normalize=False, **self.kwds) | ||
|
||
# Define default roll function to be called in apply method |
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.
move the comment to a doc-string
thanks! |
The implementations of CustomBusinessMonthBegin.apply and CustomBusinessMonthEnd.apply are merged.
Simplify CustomBusinessMonth.apply so that it uses liboffsets.roll_convention instead of liboffsets.roll_monthday (the latter being much more of a footgun). This is the last place where roll_monthday was used, so this removes it.
git diff upstream/master -u -- "*.py" | flake8 --diff