Skip to content

REF: cdef BusinessHourMixin #34342

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
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/source/reference/offset_frequency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Properties
BusinessHour.normalize
BusinessHour.rule_code
BusinessHour.n
BusinessHour.start
BusinessHour.end

Methods
~~~~~~~
Expand Down Expand Up @@ -159,6 +161,8 @@ Properties
CustomBusinessHour.normalize
CustomBusinessHour.rule_code
CustomBusinessHour.n
CustomBusinessHour.start
CustomBusinessHour.end

Methods
~~~~~~~
Expand Down
19 changes: 12 additions & 7 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,13 @@ cdef class BaseOffset:
self.__dict__.update(state)

if 'weekmask' in state and 'holidays' in state:
calendar, holidays = _get_calendar(weekmask=self.weekmask,
holidays=self.holidays,
weekmask = state.pop("weekmask")
holidays = state.pop("holidays")
calendar, holidays = _get_calendar(weekmask=weekmask,
holidays=holidays,
calendar=None)
object.__setattr__(self, "calendar", calendar)
object.__setattr__(self, "holidays", holidays)
self.calendar = calendar
self.holidays = holidays

def __getstate__(self):
"""Return a pickleable state"""
Expand Down Expand Up @@ -1024,9 +1026,12 @@ cdef class BusinessMixin(SingleConstructorOffset):
self._offset = state["_offset"]


class BusinessHourMixin(BusinessMixin):
cdef class BusinessHourMixin(BusinessMixin):
_adjust_dst = False

cdef readonly:
tuple start, end

def __init__(
self, n=1, normalize=False, start="09:00", end="17:00", offset=timedelta(0)
):
Expand Down Expand Up @@ -1073,8 +1078,8 @@ class BusinessHourMixin(BusinessMixin):
"one another"
)

object.__setattr__(self, "start", start)
object.__setattr__(self, "end", end)
self.start = start
self.end = end

def __reduce__(self):
return type(self), (self.n, self.normalize, self.start, self.end, self.offset)
Expand Down