B []R$@sddlmZmZmZddlZddlZddlmZddlmZddl Z ddl m Z m Z mZmZmZmZmZmZmZmZmZddlmZmZmZmZmZmZm Z m!Z!m"Z"ddl#m$Z$ddl%m&Z&m'Z'm(Z(dd l)m*Z*dd l+m,Z,dd l-m.Z.d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/g$Z/d0d1Z0d2d3Z1Gd4d/d/eZ2Gd5d6d6e2Z3Gd7d8d8Z4Gd9d:d:Z5Gd;d d e5e3Z6Gddde7e3Z8Gd?dde4e6Z9Gd@dde4e7e3Z:GdAdBdBe3Z;GdCdde;ZGdGdHdHe;Z?GdIdJdJe4e5e;Z@e'dKdLe&e@jAGdMdNdNe@ZBe'dOdLe&e@jAGdPdQdQe@ZCGdRdSdSe2ZDGdTddeDZEGdUddeDZFGdVd&d&e2ZGGdWdXdXZHGdYd'd'eHe2ZIGdZd#d#eHe2ZJGd[d\d\e2ZKGd]d"d"eKZLGd^d d eKZMGd_d!d!eKZNGd`ddeKZOGdadbdbe2ZPGdcddePZQGddddePZRGdeddePZSGdfddePZTGdgd%d%e2ZUGdhd$d$e2ZVGdid(d(e2ZWdjdkZXGdldmdmejYe3ZZdndoZ[Gdpd d eZZ\Gdqd)d)eZZ]Gdrd*d*eZZ^Gdsd+d+eZZ_Gdtd,d,eZZ`Gdud-d-eZZaGdvd.d.eZZbe6Zce>Zde?ZeeBZfeCZge9ZhdddecfdwdxZidydzeTeSeReQe6e?e>eLeMe8e9eBeCe:e.wrapper) functoolswraps)r[r\rH)r[rI apply_wraps^s7r_c@seZdZdZeejjZdZdZ e ddge e j ZdZd#ddZedd Zed d Zd d ZddZeddZddZddZddZeddZeddZeddZddZed d!Z d"S)$rEa Standard kind of date increment used for a date range. Works exactly like relativedelta in terms of the keyword args you pass in, use of the keyword n is discouraged-- you would be better off specifying n in the keywords you use, but regardless it is there for you. n is needed for DateOffset subclasses. DateOffset work as follows. Each offset specify a set of dates that conform to the DateOffset. For example, Bday defines this set to be the set of dates that are weekdays (M-F). To test if a date is in the set of a DateOffset dateOffset we can use the onOffset method: dateOffset.onOffset(date). If a date is not on a valid date, the rollback and rollforward methods can be used to roll the date to the nearest valid date before/after the date. DateOffsets can be created to move dates forward a given number of valid dates. For example, Bday(2) can be added to a date to move it two business days forward. If the date does not start on a valid date, first it is moved to a valid date. Thus pseudo code is: def __add__(date): date = rollback(date) # does nothing if date is valid return date + When a date offset is created for a negative number of periods, the date is first rolled forward. The pseudo code is: def __add__(date): date = rollforward(date) # does nothing is date is valid return date + Zero presents a problem. Should it roll forward or back? We arbitrarily have it rollforward: date + BDay(0) == BDay.rollforward(date) Since 0 is a bit weird, we suggest avoiding its use. Parameters ---------- n : int, default 1 The number of time periods the offset represents. normalize : bool, default False Whether to round the result of a DateOffset addition down to the previous midnight. **kwds Temporal parameter that add to or replace the offset value. Parameters that **add** to the offset (like Timedelta): - years - months - weeks - days - hours - minutes - seconds - microseconds - nanoseconds Parameters that **replace** the offset value: - year - month - day - weekday - hour - minute - second - microsecond - nanosecond See Also -------- dateutil.relativedelta.relativedelta Examples -------- >>> ts = pd.Timestamp('2017-01-01 09:10:11') >>> ts + DateOffset(months=3) Timestamp('2017-04-01 09:10:11') >>> ts = pd.Timestamp('2017-01-01 09:10:11') >>> ts + DateOffset(month=3) Timestamp('2017-03-01 09:10:11') FnrTcKs`t|||t|\}}t|d|t|d|x"|D]}||}t|||q>WdS)N_offset_use_relativedelta)r__init__ liboffsetsZ_determine_offsetobject __setattr__)rXr`rTkwdsoffZuse_rdkeyvalrHrHrIrds zDateOffset.__init__cCs|jrt|}t|jdkrt|dd}|dk rB|jrB|jdd}|jdkrlx>t|jD]}||j}qXWn xt|j D]}||j}qzW|dk r|jrt ||}t |S|t |jSdS)NrrK)rK) rcrlenrhrPreplacer`rangerbr rSrJr)rXrYrKirHrHrIapply s    zDateOffset.applyc Cs`t|tk r tdj|jjd|j}ddddddd d h}|jrt| |r| dd d | dd |j }|rt |j|}t|||jd }| dd |j }|r|d}t|jtjs|j}||}||d}dd|D}|rtf|} ||j | }|S|js@t|dr@||j|j St||} tdj| ddS)a Vectorized apply of DateOffset to DatetimeIndex, raises NotImplentedError for offsets without a vectorized implementation. Parameters ---------- i : DatetimeIndex Returns ------- y : DatetimeIndex zDDateOffset subclass {name} does not have a vectorized implementation)nameyearsmonthsweeksdayshoursminutesseconds microsecondsr )dtypeWcSsi|]\}}|dkr||qS))rurvrwrxryrH).0kvrHrHrI Ysz*DateOffset.apply_index..rbzPDateOffset with relativedelta keyword(s) {kwd} not able to be applied vectorized)kwdN)typerENotImplementedErrorformat __class____name__rhrcsetissubsetgetr`re shift_monthsasi8r{ to_periodrF_datarNndarray _time_shift to_timestampto_perioddeltaitemsr hasattrrb) rXrorhZrelativedelta_fastrsshiftedrtasperZtimedelta_kwdsdeltarrHrHrI apply_index%sJ "     zDateOffset.apply_indexcCs |jdkS)Nra)r`)rXrHrHrI isAnchorednszDateOffset.isAnchoredcCs|dddh}g}xNt|jD]@}|ds|dkr4qq||krt||}|dj||dqWd}|rx|d d |7}|S) Nr`incrT_rhz{attr}={value})attrrVz: z, )sorted__dict__ startswithrPappendrjoin)rXexcludeattrsrrVoutrHrHrI _repr_attrsvs  zDateOffset._repr_attrscCs|jS)N) rule_code)rXrHrHrIrqszDateOffset.namecCs2t|}||s.||jdd|ji|j}|S)z Roll provided date backward to next offset only if not on offset. Returns ------- TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp. rarT)ra)rJonOffsetrrTrh)rXdtrHrHrIrollbacks  zDateOffset.rollbackcCs2t|}||s.||jdd|ji|j}|S)z Roll provided date forward to next offset only if not on offset. Returns ------- TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp. rarT)ra)rJrrrTrh)rXrrHrHrI rollforwards  zDateOffset.rollforwardcCsD|jrt|sdSt|tks(t|tr,dS|}|||}||kS)NFT)rTrrrErFrM)rXrabrHrHrIrs zDateOffset.onOffsetcCs tddS)NzPrefix not defined)r)rXrHrHrI_prefixszDateOffset._prefixcCs|jS)N)r)rXrHrHrIrszDateOffset.rule_codecCsty |j}Wntk r"t|SX|jdkr@dj|j|d}n|}y|jrX||7}Wntk rnYnX|S)Nraz {n}{code})r`code)rrreprr`rrb _offset_strAttributeError)rXrZfstrrHrHrIfreqstrs   zDateOffset.freqstrcCsdS)NrrH)rXrHrHrIrszDateOffset._offset_strcCstdj|ddS)Nz{name} is a non-fixed frequency)rq) ValueErrorr)rXrHrHrInanosszDateOffset.nanosN)raF)!r __module__ __qualname____doc__rr_paramsfgetrcrQ frozensetlistreZrelativedelta_kwds _attributesrTrdr_rprrrrpropertyrqrrrrrrrrrHrHrHrIrEs(Z   I    c@seZdZedddZdS)SingleConstructorOffsetNcCs|rtdj|d|S)NzBad freq suffix {suffix})suffix)rr)clsrrHrHrI _from_namesz"SingleConstructorOffset._from_name)N)rrr classmethodrrHrHrHrIrsrc@seZdZdZddZdS) _CustomMixinze Mixin for classes that define and validate calendar, holidays, and weekdays attributes. cCs@t|||d\}}t|d|t|d|t|d|dS)N)weekmaskholidayscalendarrrr)rrfrg)rXrrrrHrHrIrds z_CustomMixin.__init__N)rrrrrdrHrHrHrIrsrc@s$eZdZdZeddZddZdS) BusinessMixinz? Mixin to business types to provide related functions. cCs|jS)z) Alias for self._offset. )rb)rXrHrHrIoffsetszBusinessMixin.offsetcCs:|jrdj|jdg}nd}d}|r6|dd|7}|S)Nzoffset={offset!r})rrz: z, )rrr)rXrrrHrHrIrszBusinessMixin._repr_attrsN)rrrrrrrrHrHrHrIrs rc@sbeZdZdZdZdZedddgZdded fd d Z d d Z e ddZ e ddZddZdS)r#zD DateOffset subclass representing possibly n business days. BTr`rTrraFrcCs t|||t|d|dS)Nrb)rrdrfrg)rXr`rTrrHrHrIrdszBusinessDay.__init__cCs`dd}t|jtrNtddd}|j|kr:d||j}nd||j }|Sdt|jSdS)NcSsd}|jdkr |t|jd7}|jdkr|j}t|d}|dkr`|t|d7}||d8}t|d}|dkr|t|d7}||d8}|dkr|t|d7}|jdkr|t|jd 7}|S) NrrDiH<ZMinsus)rustrrxintry)tdoff_strrZhrsZmtsrHrHrIget_strs$       z(BusinessDay._offset_str..get_strr+-)rFrrr)rXrzerorrHrHrIrs   zBusinessDay._offset_strcCst|tr|j}|}|d}|dkr8|dkr8|d7}|d|8}|dkr^|dkr^d|}n4|dkrxd||d}n||dkr|}n|d}|td||d}|jr||j}|St|ttfrt|j|j||jdSt d dS) Nrra)ru)rrTzAOnly know how to combine business day with datetime or timedelta.) rFrr`weekdayrrrMr$rTr)rXrYr`wdayrtrurZrHrHrIrp9s,     zBusinessDay.applycCs|d}|d}t|jtjs(|j}|jdkrl|d|jdk}t||jd|j}| |t j }n|j}| |}| |}|S)Nrrrra)rrrFrrNrr`rwhere_addsub_int_arrayoperatoraddrr)rXrotimerrrollrZrHrHrIras     zBusinessDay.apply_indexcCs|jrt|sdS|dkS)NFr)rTrr)rXrrHrHrIrzszBusinessDay.onOffsetN)rrrrrrQrrrrdrr_rprrrrHrHrHrIr# s ( cseZdZddedfddZeddZdd d Zd d Zd dZ e ddZ e ddZ ddZ e ddZddZddZfddZZS)BusinessHourMixinz09:00z17:00rcCs4t|s|g}t|stdt|s,|g}t|ssz.BusinessHourMixin.__init__..cSsg|]}t|qSrH)rer)r}rrHrHrIrsz8number of starting time and ending time must be the samerraiQz_invalid starting and ending time(s): opening hours should not touch or overlap with one anotherstartendrb) r rlrrNarrayZargsorttuplern_get_business_hours_by_secrfrg)rXrrrZ num_openingsindexZ total_secsrorHrHrIrds8    zBusinessHourMixin.__init__cCsD|jdkrd}nd}|jdr6t||j|j|jdSt|dSdS)z7 Used for moving to next business day. rraC)r`rrr)r`N)r`rrr%rrrr#)rXZ nb_offsetrHrHrI next_bdays   zBusinessHourMixin.next_bdayracCs6|jd}|jd}|j|s\|||j}|j|dkrL|j|j}}n|j|j}}n|j|dkr||kr|||j}|j|j}}n,x|jD] }||kr|j|j}}PqWn^||kr|||j}|j|j}}n4x2t|jD]$}||kr|j|j}}PqWt|j |j |j ||S)a If self.n and sign have the same sign, return the earliest opening time later than or equal to current time. Otherwise the latest opening time earlier than or equal to current time. Opening time always locates on BusinessDay. However, closing time may not if business hour extends over midnight. Parameters ---------- other : datetime Current time. sign : int, default 1. Either 1 or -1. Going forward in time if it has the same sign as self.n. Going backward in time otherwise. Returns ------- result : datetime Next opening time. rr) rrrr`hourminuterreversedryearmonthday)rXrYsignZearliest_startZ latest_startrrstrHrHrI_next_opening_times.       z$BusinessHourMixin._next_opening_timecCs|j|ddS)a If n is positive, return the latest opening time earlier than or equal to current time. Otherwise the earliest opening time later than or equal to current time. Parameters ---------- other : datetime Current time. Returns ------- result : datetime Previous opening time. r)r)r)rXrYrHrHrI_prev_opening_timesz$BusinessHourMixin._prev_opening_timecCsHtddd|j|j}||kr dnd}tdd||j|j}t||S)z< Return business hours in a day by seconds. irrar)rrrr total_seconds)rXrrZdtstartrZuntilrHrHrIrsz,BusinessHourMixin._get_business_hours_by_seccCs8||s4|jdkr ||}n ||}||S|S)zS Roll provided date backward to next offset only if not on offset. r)rr`rr_get_closing_time)rXrrHrHrIrs      zBusinessHourMixin.rollbackcCs,||s(|jdkr||S||S|S)zR Roll provided date forward to next offset only if not on offset. r)rr`rr)rXrrHrHrIr(s     zBusinessHourMixin.rollforwardcCsXxJt|jD]<\}}|j|jkr |j|jkr |t|||j|dSq WdsTtdS)a- Get the closing time of a business hour interval by its opening time. Parameters ---------- dt : datetime Opening time of a business hour interval. Returns ------- result : datetime Corresponding closing time. )rxFN) enumeraterrrrrrAssertionError)rXrrorrHrHrIr4s z#BusinessHourMixin._get_closing_timec s<t|tr0t|dd}t|j|j|j|j|j|j|j }j }|dkrl| j ks` |s|}n:| jkr|tdd} |s|}|}tfddtjj D}tt|d|d\}}|dkr| | }}|dkr@t|d}j|s8|}||} ||| }n||}t|d } |dkrx| tdkr||} | | kr|| 7}td} n| | 8} || }qVWnzxx| tdkr*||} | | ks| | kr|dkr|| 7}td} n&| | 8} || tdd}qW|Std dS) NrLrra)rxc3s|]\}}||VqdS)N)r)r}ren)rXrHrI isz*BusinessHourMixin.apply..r)r`)rwz4Only know how to combine business hour with datetime)rFrrPrrrrrsecond microsecondr`rr _onOffsetrrrrsumzipdivmodabsr#rrrr) rXrYrLr` businesshoursZbdrZskip_bdZ prev_openZremainZ bhour_remainZbhourrH)rXrIrpIsl                  zBusinessHourMixin.applycCsH|jrt|sdS|jdk r>t|j|j|j|j|j|j |j }| |S)NF) rTrrKrrrrrrrrr)rXrrHrHrIrs   zBusinessHourMixin.onOffsetcCs|jdkr||}n ||}||}d}x@t|jD]2\}}|j|jkr<|j|jkr<|||j |}q.z{prefix}={hours})prefixrvz: z, )superrrrrrrr)rXrrvr)rrHrIrs zBusinessHourMixin._repr_attrs)ra)rrrrrdrrrrrr_rrrrprrr __classcell__rHrH)rrIrs.  ;  ] rcsJeZdZdZdZdZedddddgZd d d d edffd d Z Z S)r/zc DateOffset subclass representing possibly n business hours. .. versionadded:: 0.16.1 ZBHrr`rTrrrraFz09:00z17:00cs$t|||tj|||ddS)N)rrr)rrdr)rXr`rTrrr)rrHrIrdszBusinessHour.__init__) rrrrr_anchorrrrrdrrHrH)rrIr/s c@s^eZdZdZdZeddddddgZd d d d d ed fddZe ddZ ddZ ddZ d S)r%au DateOffset subclass representing possibly n custom business days, excluding holidays. Parameters ---------- n : int, default 1 normalize : bool, default False Normalize start/end dates to midnight before generating date range weekmask : str, Default 'Mon Tue Wed Thu Fri' weekmask of valid business days, passed to ``numpy.busdaycalendar`` holidays : list list/array of dates to exclude from the set of valid business days, passed to ``numpy.busdaycalendar`` calendar : pd.HolidayCalendar or np.busdaycalendar offset : timedelta, default timedelta(0) rr`rTrrrrraFzMon Tue Wed Thu FriNrcCs0t|||t|d|t||||dS)Nrb)rrdrfrgr)rXr`rTrrrrrHrHrIrds zCustomBusinessDay.__init__cCs|jdkrd}nd}t|trt|}t|}tj||j||jd}|t}t || }|j rp||j }|St|t t frt|j|j ||jdStddS)NrforwardZbackward)r busdaycal)rrTzLOnly know how to combine trading day with datetime, datetime64 or timedelta.)r`rFrrNrOrZ busday_offsetrastypecombinerrrrMr$rTr)rXrYrZdate_inZnp_dtZ np_incr_dtZdt_daterZrHrHrIrp s"    zCustomBusinessDay.applycCstdS)N)r)rXrorHrHrIr)szCustomBusinessDay.apply_indexcCs,|jrt|sdSt|d}tj||jdS)NFz datetime64[D])r)rTrrrNZ is_busdayr)rXrZday64rHrHrIr,s zCustomBusinessDay.onOffset) rrrrrrrrrdr_rprrrHrHrHrIr%s c @sNeZdZdZdZdZedddddd d d gZd d dddddedfddZ dS)r0zi DateOffset subclass representing possibly n custom business days. .. versionadded:: 0.18.1 ZCBHrr`rTrrrrrrraFzMon Tue Wed Thu FriNz09:00z17:00c CsBt|||t|d|t||||tj||||ddS)Nrb)rrr)rrdrfrgrr) rXr`rTrrrrrrrHrHrIrd@s zCustomBusinessHour.__init__) rrrrrrrrrrdrHrHrHrIr03sc@sNeZdZdZeddgZejZeddZ ddZ e dd Z e d d Zd S) MonthOffsetTr`rTcCs,|jr |jStj|j}dj|j|dSdS)Nz{code}-{month})rr)rrr MONTH_ALIASESr`r)rXrrHrHrIrq\s zMonthOffset.namecCs"|jrt|sdS|j||kS)NF)rTrr_get_offset_day)rXrrHrHrIrdszMonthOffset.onOffsetcCs*||}t|j|j|}t|||jS)N)rreroll_conventionrr`r_day_opt)rXrY compare_dayr`rHrHrIrpis zMonthOffset.applycCs,t|j|j|j}t|j||j|jdS)N)freqr{) rerrr`rr _simple_newrr{)rXrorrHrHrIroszMonthOffset.apply_indexN)rrrrQrrrrdrrqrr_rprrrHrHrHrIrVs   rc@seZdZdZdZdZdS)r+z& DateOffset of one month end. MrN)rrrrrrrHrHrHrIr+wsc@seZdZdZdZdZdS)r)z/ DateOffset of one month at beginning. ZMSrN)rrrrrrrHrHrHrIr)sc@seZdZdZdZdZdS)BusinessMonthEndz; DateOffset increments between business EOM dates. ZBM business_endN)rrrrrrrHrHrHrIrsrc@seZdZdZdZdZdS)BusinessMonthBeginz8 DateOffset of one business month at beginning. ZBMSbusiness_startN)rrrrrrrHrHrHrIr sr c@szeZdZdZeddddddgZejZejZdd d d d e d fd dZ e ddZ e ddZ e ddZeddZd S)_CustomBusinessMontha DateOffset subclass representing custom business month(s). Increments between %(bound)s of month dates. Parameters ---------- n : int, default 1 The number of months represented. normalize : bool, default False Normalize start/end dates to midnight before generating date range. weekmask : str, Default 'Mon Tue Wed Thu Fri' Weekmask of valid business days, passed to ``numpy.busdaycalendar``. holidays : list List/array of dates to exclude from the set of valid business days, passed to ``numpy.busdaycalendar``. calendar : pd.HolidayCalendar or np.busdaycalendar Calendar to integrate. offset : timedelta, default timedelta(0) Time offset to apply. r`rTrrrrraFzMon Tue Wed Thu FriNrcCs0t|||t|d|t||||dS)Nrb)rrdrfrgr)rXr`rTrrrrrHrHrIrds z_CustomBusinessMonth.__init__cCs6tf|jdd|j}|jdr,|j}n|j}|S)zL Define default roll function to be called in apply method. F)r`rTS)r%r`rhrendswithrr)rXZcbday roll_funcrHrHrI cbday_rolls  z_CustomBusinessMonth.cbday_rollcCs*|jdrtddd}n tddd}|S)Nr#raF)r`rT)rr$r)r+)rXmoffrHrHrIm_offsets  z_CustomBusinessMonth.m_offsetcCs"|jdr|jj}n|jj}|S)zL Define default roll function to be called in apply method. r#)rr$r(rr)rXr%rHrHrI month_rolls  z_CustomBusinessMonth.month_rollcCsD||}||}t|j|j|j}|||j}||}|S)N)r)r&rerrr`r()rXrYZcur_month_offset_dateZ compare_dater`newrZrHrHrIrps    z_CustomBusinessMonth.apply)rrrrrrrErrrrdrr&r(r)r_rprHrHrHrIr"s  r"r)boundc@seZdZdZdS)CustomBusinessMonthEndZCBMN)rrrrrHrHrHrIr,sr,Z beginningc@seZdZdZdS)CustomBusinessMonthBeginZCBMSN)rrrrrHrHrHrIr-sr-c@szeZdZdZdZdZedddgZdd d Ze dd d Z e ddZ e ddZddZeddZddZddZd S)SemiMonthOffsetTrr`rT day_of_monthraFNcCsrt||||dkr(t|d|jnt|dt||j|jkrRdksnnd}t|j |j|jddS)Nr0z7day_of_month must be {min}<=day_of_month<=27, got {day})minr) rrdrfrg_default_day_of_monthr_min_day_of_monthr0rr)rXr`rTr0msgrHrHrIrdszSemiMonthOffset.__init__cCs ||dS)N)r0rH)rrrHrHrIrszSemiMonthOffset._from_namecCsdj|jd}|j|S)Nz-{day_of_month})r0)rr0r)rXrrHrHrIr"szSemiMonthOffset.rule_codecCst|j|j|j}t|j|j}t |t krN|jdkrN|jdkrN|d8}n(t |t krv|jdkrv|j|krv|d7}| ||S)Nrra) rerrr`r0r get_days_in_monthrrrr.r-_apply)rXrYr` days_in_monthrHrHrIrp's   zSemiMonthOffset.applycCs t|dS)z@ Handle specific apply logic for child classes. N)r)rXr`rYrHrHrIr7:szSemiMonthOffset._applyc Cs|}|dj}t|jddj}||k}||k}||||}|d}|d} t| jt j sh| j} | |dt j } t|| }|||}||S)Nrra)rurr)rrr r0rV _get_rollrrFrrNrrrrrr_apply_index_days) rXroZdtiZdays_from_startrbefore_day_of_monthafter_day_of_monthrrrrrHrHrIr@s    zSemiMonthOffset.apply_indexcCs t|dS)z Return an array with the correct n for each date in i. The roll array is based on the fact that i gets rolled back to the first day of the month. N)r)rXror;r<rHrHrIr9dszSemiMonthOffset._get_rollcCs t|dS)z; Apply the correct day for each date in i. N)r)rXrorrHrHrIr:msz!SemiMonthOffset._apply_index_days)raFN)N)rrrrQr3r4rrrdrrrrr_rpr7rrr9r:rHrHrHrIr. s     $ r.c@s8eZdZdZdZdZddZddZdd Zd d Z d S) r-a Two DateOffset's per month repeating on the last day of the month and day_of_month. .. versionadded:: 0.19.0 Parameters ---------- n : int normalize : bool, default False day_of_month : int, {1, 3,...,27}, default 15 ZSMracCs2|jrt|sdSt|j|j}|j|j|fkS)NF)rTrr r6rrrr0)rXrr8rHrHrIrszSemiMonthEnd.onOffsetcCs&|d}|drdn|j}t|||S)Nr)r0r)rXr`rYrsrrHrHrIr7szSemiMonthEnd._applyc Cs|j}|j}|dkr>t|dd}t|||d}||}nF|dkrnt|dd} t|dd}|| }nt||d|d}|S)Nrrar)r` is_month_endrNr) rXror;r<r`r>Zroll_endZ roll_beforer roll_afterrHrHrIr9s  zSemiMonthEnd._get_rollcCs2|dt|jdj}||d7}|tddS)z Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex r)ruztimedelta64[ns]r)r r0rVr)rXrorrrHrHrIr:s zSemiMonthEnd._apply_index_daysN) rrrrrr4rr7r9r:rHrHrHrIr-ts c@s4eZdZdZdZddZddZddZd d Zd S) r.a Two DateOffset's per month repeating on the first day of the month and day_of_month. .. versionadded:: 0.19.0 Parameters ---------- n : int normalize : bool, default False day_of_month : int, {2, 3,...,27}, default 15 ZSMScCs"|jrt|sdS|jd|jfkS)NFra)rTrrr0)rXrrHrHrIrszSemiMonthBegin.onOffsetcCs.|d|d}|drdn|j}t|||S)Nrra)r0r)rXr`rYrsrrHrHrIr7szSemiMonthBegin._applyc Cs|j}|j}|dkr(t|||d}nZ|dkrVt|dd}t|dd}||}n,t||d|d}t|dd}||}|S)Nrrarr)r`is_month_startrNr) rXror;r<r`r@rZ roll_startr?rHrHrIr9s zSemiMonthBegin._get_rollcCs(|dt|jddj}||dS)z Add days portion of offset to DatetimeIndex i. Parameters ---------- i : DatetimeIndex roll : ndarray[int64_t] Returns ------- result : DatetimeIndex rra)ruztimedelta64[ns])r r0rVr)rXrorrrHrHrIr:s z SemiMonthBegin._apply_index_daysN) rrrrrrr7r9r:rHrHrHrIr.s  c@seZdZdZdZeddZdZedddgZ dd d Z d dZ e ddZ eddZddZddZeddZedddZd S)r<z Weekly offset. Parameters ---------- weekday : int, default None Always generate specific day of week. 0 for Monday Tra)rtr|r`rTrFNcCsPt|||t|d||jdk rL|jdks:|jdkrLtdj|jddS)Nrrz Day must be 0<=day<=6, got {day})r)rrdrfrgrrr)rXr`rTrrHrHrIrds  z Week.__init__cCs|jdko|jdk S)Nra)r`r)rXrHrHrIrszWeek.isAnchoredcCsf|jdkr||j|jS|j}|}||jkrX|t|j|d}|dkrX|d8}|t|dS)Nrrra)rt)rr`_incr)rXrYr~ZotherDayrHrHrIrp s  z Week.applycCsT|jdkrF|d}t|jtjs(|j}||j}|| dS| |SdS)Nr|) rrrFrrNrrr`rr_end_apply_index)rXrorrrHrHrIrs   zWeek.apply_indexc Cs|d}t|j\}}||}t|jtjs8|j}|j dkr||t ddt dd}t |j dd|k|j |j d}| |tj}|j dd}n|j }||j dd}||t ddt ddS)z Add self to the given DatetimeIndex, specialized for case where self.weekday is non-null. Parameters ---------- dtindex : DatetimeIndex Returns ------- result : DatetimeIndex rrransr)how)rlibfrequenciesZ get_freq_coderrrFrrNrr`r rrrrrr) rXdtindexribaseZmultZ base_periodZnormedrrrHrHrIrC(s   zWeek._end_apply_indexcCs.|jrt|sdS|jdkr dS||jkS)NFT)rTrr)rXrrHrHrIrOs  z Week.onOffsetcCs0d}|jdk r&tj|j}dj|d}|j|S)Nrz -{weekday})r)rr int_to_weekdayrr)rXrrrHrHrIrVs    zWeek.rule_codecCs|s d}n tj|}||dS)N)r)r weekday_to_int)rrrrHrHrIr^s zWeek._from_name)raFN)N)rrrrrQrrBrrrrdrr_rprrrCrrrrrrHrHrHrIr<s    ' c@s$eZdZdZeddZddZdS)_WeekOfMonthMixinzF Mixin for methods common to WeekOfMonth and LastWeekOfMonth. cCsn||}|j}|dkr,||jkr,|d8}n|dkrF||jkrF|d7}t||d}||}t|||jS)Nrrar)rr`rrre shift_day)rXrYrrsrZto_dayrHrHrIrpls    z_WeekOfMonthMixin.applycCs"|jrt|sdS|j||kS)NF)rTrrr)rXrrHrHrIrzsz_WeekOfMonthMixin.onOffsetN)rrrrr_rprrHrHrHrIrKgs rKc@sTeZdZdZdZdZeddddgZdd d Zd dZ e ddZ e dddZ dS)r=a Describes monthly dates like "the Tuesday of the 2nd week of each month". Parameters ---------- n : int week : {0, 1, 2, 3, ...}, default 0 0 is 1st week of month, 1 2nd week, etc. weekday : {0, 1, ..., 6}, default 0 0: Mondays 1: Tuesdays 2: Wednesdays 3: Thursdays 4: Fridays 5: Saturdays 6: Sundays ZWOMTr`rTweekrraFrcCszt|||t|d|t|d||jdks>|jdkrPtdj|jd|jdksd|jdkrvtdj|jd dS) NrrMrrAz Day must be 0<=day<=6, got {day})rz#Week must be 0<=week<=3, got {week})rM)rrdrfrgrrrrM)rXr`rTrMrrHrHrIrdszWeekOfMonth.__init__cCs8t|j|jd}|}|j|d}d||jdS)a  Find the day in the same month as other that has the same weekday as self.weekday and is the self.week'th such day in the month. Parameters ---------- other : datetime Returns ------- day : int rar)rrrrrM)rXrYZmstartr shift_daysrHrHrIrs zWeekOfMonth._get_offset_daycCs(tj|jd}dj|j|jd|dS)Nrz{prefix}-{week}{weekday}ra)r rMr)r rIrrrrrM)rXrrHrHrIrszWeekOfMonth.rule_codeNcCsD|stdj|jdt|dd}tj|dd}|||dS)Nz$Prefix {prefix!r} requires a suffix.)r rra)rMr)rrrrr rJ)rrrMrrHrHrIrs zWeekOfMonth._from_name)raFrr)N)rrrrrrQrrrdrrrrrrHrHrHrIr=s  c@sReZdZdZdZdZedddgZdd d Zd d Z e ddZ e dddZ dS)r9aM Describes monthly dates in last week of month like "the last Tuesday of each month". Parameters ---------- n : int, default 1 weekday : {0, 1, ..., 6}, default 0 0: Mondays 1: Tuesdays 2: Wednesdays 3: Thursdays 4: Fridays 5: Saturdays 6: Sundays ZLWOMTr`rTrraFrcCsXt|||t|d||jdkr.td|jdksB|jdkrTtdj|jddS)Nrrz N cannot be 0rAz Day must be 0<=day<=6, got {day})r)rrdrfrgr`rrr)rXr`rTrrHrHrIrds zLastWeekOfMonth.__init__cCs>t|j|j}t|j|j|}|}||jd}||S)a Find the day in the same month as other that has the same weekday as self.weekday and is the last such day in the month. Parameters ---------- other: datetime Returns ------- day: int r)r r6rrrr)rXrYdimmendrrOrHrHrIrs zLastWeekOfMonth._get_offset_daycCs tj|jd}dj|j|dS)Nrz{prefix}-{weekday})r r)r rIrrrr)rXrrHrHrIrszLastWeekOfMonth.rule_codeNcCs*|stdj|jdtj|}||dS)Nz$Prefix {prefix!r} requires a suffix.)r )r)rrrr rJ)rrrrHrHrIrs  zLastWeekOfMonth._from_name)raFr)N)rrrrrrQrrrdrrrrrrHrHrHrIr9s  c@sveZdZdZdZdZdZedddgZdd d Z d d Z e dd dZ e ddZeddZddZeddZdS) QuarterOffsetz6 Quarter representation - doesn't call super. NTr`rT startingMonthraFcCs.t||||dkr|j}t|d|dS)NrS)rrd_default_startingMonthrfrg)rXr`rTrSrHrHrIrd!szQuarterOffset.__init__cCs|jdko|jdk S)Nra)r`rS)rXrHrHrIr(szQuarterOffset.isAnchoredcCs6i}|rtj||d<n|jdk r,|j|d<|f|S)NrS)r MONTH_TO_CAL_NUM_from_name_startingMonth)rrkwargsrHrHrIr+s   zQuarterOffset._from_namecCstj|j}dj|j|dS)Nz{prefix}-{month})r r)r rrSrr)rXrrHrHrIr5s zQuarterOffset.rule_codecCsH|jd|jd}tj||j|j|jdd}|d|}t|||jS)NrN)Zday_optmodby)rrSreZ roll_qtrdayr`rr)rXrYZ months_sinceZqtrsrsrHrHrIrp:s  zQuarterOffset.applycCs:|jrt|sdS|j|jd}|dko8|j||kS)NFrNr)rTrrrSrr)rXrZ mod_monthrHrHrIrHszQuarterOffset.onOffsetcCs0t|j|j|j|j}t|j||j|j dS)N)rr{) reshift_quartersrr`rSrrrrr{)rXrGrrHrHrIrNszQuarterOffset.apply_index)raFN)N)rrrrrTrVrQrrrdrrrrrr_rprrrrHrHrHrIrRs   rRc@s$eZdZdZdZdZdZdZdZdS)r8a DateOffset increments between business Quarter dates. startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ... startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ... startingMonth = 3 corresponds to dates like 3/30/2007, 6/29/2007, ... ZBusinessQuarterEndrNrzZBQrN) rrrr _outputNamerTrVrrrHrHrHrIr8Zs c@s eZdZdZdZdZdZdZdS)r6ZBusinessQuarterBeginrNraZBQSr!N)rrrrZrTrVrrrHrHrHrIr6ks c@s eZdZdZdZdZdZdZdS)r7a DateOffset increments between business Quarter dates. startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ... startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ... startingMonth = 3 corresponds to dates like 3/31/2007, 6/30/2007, ... rNQrN)rrrrrZrTrrrHrHrHrIr7ts c@s eZdZdZdZdZdZdZdS)r5rNraZQSrN)rrrrZrTrVrrrHrHrHrIr5s c@sneZdZdZdZedddgZddZedd Z e d d Z d d Z dddZ edddZeddZdS) YearOffsetz- DateOffset that just needs a month. Tr`rTrcCst|j|jd|jS)N)r)reZget_day_of_monthrmrr)rXrYrHrHrIrszYearOffset._get_offset_daycCs6t||j|j|j}|d|j|j}t|||jS)Nrz)rr`rrr)rXrYrrrsrHrHrIrpszYearOffset.applycCs4tj|j|j|j|jdd}t|j||j|j dS)Nrz)rX)rr{) rerYrr`rrrrrr{)rXrGrrHrHrIrszYearOffset.apply_indexcCs.|jrt|sdS|j|jko,|j||kS)NF)rTrrrr)rXrrHrHrIrszYearOffset.onOffsetraFNcCsNt||||dk r|n|j}t|d||jdksB|jdkrJtddS)NrrarzzMonth must go from 1 to 12)rrd_default_monthrfrgrr)rXr`rTrrHrHrIrds zYearOffset.__init__cCs i}|rtj||d<|f|S)Nr)r rU)rrrWrHrHrIrszYearOffset._from_namecCstj|j}dj|j|dS)Nz{prefix}-{month})r r)r rrrr)rXrrHrHrIrs zYearOffset.rule_code)raFN)N)rrrrrQrrrr_rprrrrdrrrrrHrHrHrIr\s    r\c@s eZdZdZdZdZdZdZdS)r4z; DateOffset increments between business EOM dates. ZBusinessYearEndrzZBArN)rrrrrZr]rrrHrHrHrIr4s c@s eZdZdZdZdZdZdZdS)r2zB DateOffset increments between business year begin dates. ZBusinessYearBeginraZBASr!N)rrrrrZr]rrrHrHrHrIr2s c@seZdZdZdZdZdZdS)r3z; DateOffset increments between calendar year ends. rzArN)rrrrr]rrrHrHrHrIr3sc@seZdZdZdZdZdZdS)r1zB DateOffset increments between calendar year begin dates. raZASrN)rrrrr]rrrHrHrHrIr1sc@seZdZdZdZdZedddgZd d d Zd dZ ddZ e ddZ ddZ eddZddZddZeddZeddZdS)!r;a Describes 52-53 week fiscal year. This is also known as a 4-4-5 calendar. It is used by companies that desire that their fiscal year always end on the same day of the week. It is a method of managing accounting periods. It is a common calendar structure for some industries, such as retail, manufacturing and parking industry. For more information see: http://en.wikipedia.org/wiki/4-4-5_calendar The year may either: - end on the last X day of the Y month. - end on the last X day closest to the last day of the Y month. X is a specific day of the week. Y is a certain month of the year Parameters ---------- n : int weekday : {0, 1, ..., 6} 0: Mondays 1: Tuesdays 2: Wednesdays 3: Thursdays 4: Fridays 5: Saturdays 6: Sundays startingMonth : The month in which fiscal years end. {1, 2, ... 12} variation : str {"nearest", "last"} for "LastOfMonth" or "NearestEndMonth" ZRETrrS variationraFrnearestcCsjt|||t|d|t|d|t|d||jdkrJtd|jdkrftdj|jddS) NrSrr_rz N cannot be 0)r`lastz${variation} is not a valid variation)r_)rrdrfrgr`rr_r)rXr`rTrrSr_rHrHrIrd!s  zFY5253.__init__cCs|jdko|jdk o|jdk S)Nra)r`rSr)rXrHrHrIr2szFY5253.isAnchoredcCsb|jrt|sdSt|j|j|j}||}|jdkrV||kpT|t|dd|kS||kSdS)NFr`r) rTrrrrr get_year_endr_r)rXrZyear_endrHrHrIr7s  zFY5253.onOffsetc Cst|}|j}|t|jd|jd}|t|j|jd}|t|jd|jd}t||j }t||j }t||j }||kr|d8}n||krn|dkr||kr|d8}n:||kr|krnn |d8}n||kr|krnnn||kr|krnn |d7}n\||kr6|kr|j|jkrp||krp||t dkrp|d8}n dszt t|j||jd}||}t|j|j |j |j|j|j|j}|S)NrarrrAF)r rTr`rbrrrSr rSrKrrrrrrrr) rXrYnormr`Z prev_yearZcur_yearZ next_yearrrZrHrHrIrpCsN         z FY5253.applycCs|jdkstt|j|j}t|j|j|}|j|}|dkrH|S|jdkrl|dd}|t |dS|d}|dkr|t |S|t |dSdS)Nrrar)rurN) rKrr r6rrSrrr_r)rXrrPZ target_dateZ wkday_diffZ days_forwardrHrHrIrb{s   zFY5253.get_year_endcCs|j}|}dj||dS)Nz{prefix}-{suffix})r r)rget_rule_code_suffixr)rXr rrHrHrIrszFY5253.rule_codecCs|jdkrdSdSdS)Nr`NL)r_)rXrHrHrI_get_suffix_prefixs zFY5253._get_suffix_prefixcCs0|}tj|j}tj|j}dj|||dS)Nz{prefix}-{month}-{weekday})r rr)rgr rrSrIrr)rXr rrrHrHrIrds   zFY5253.get_rule_code_suffixcCsL|dkrd}n|dkrd}ntdj|dtj|}tj|}|||dS)Nrer`rfraz#Unable to parse varion_code: {code})r)rrSr_)rrr rUrJ)rZ varion_codeZstartingMonth_codeZ weekday_coder_rSrrHrHrI _parse_suffixs  zFY5253._parse_suffixcGs|f|j|S)N)rh)rargsrHrHrIrszFY5253._from_nameN)raFrrar`)rrrrrrQrrrdrrr_rprbrrrgrdrrhrrHrHrHrIr;s#  8  c@seZdZdZdZdZeddddgZd!d d Ze ddZ ddZ ddZ e ddZddZddZddZeddZeddZd S)"r:ar DateOffset increments between business quarter dates for 52-53 week fiscal year (also known as a 4-4-5 calendar). It is used by companies that desire that their fiscal year always end on the same day of the week. It is a method of managing accounting periods. It is a common calendar structure for some industries, such as retail, manufacturing and parking industry. For more information see: http://en.wikipedia.org/wiki/4-4-5_calendar The year may either: - end on the last X day of the Y month. - end on the last X day closest to the last day of the Y month. X is a specific day of the week. Y is a certain month of the year startingMonth = 1 corresponds to dates like 1/31/2007, 4/30/2007, ... startingMonth = 2 corresponds to dates like 2/28/2007, 5/31/2007, ... startingMonth = 3 corresponds to dates like 3/30/2007, 6/29/2007, ... Parameters ---------- n : int weekday : {0, 1, ..., 6} 0: Mondays 1: Tuesdays 2: Wednesdays 3: Thursdays 4: Fridays 5: Saturdays 6: Sundays startingMonth : The month in which fiscal years end. {1, 2, ... 12} qtr_with_extra_week : The quarter number that has the leap or 14 week when needed. {1,2,3,4} variation : str {"nearest", "last"} for "LastOfMonth" or "NearestEndMonth" ZREQTrrSqtr_with_extra_weekr_raFrr`cCs\t|||t|d|t|d|t|d|t|d||jdkrXtddS)NrSrrjr_rz N cannot be 0)rrdrfrgr`r)rXr`rTrrSrjr_rHrHrIrds  zFY5253Quarter.__init__cCst|j|j|jdS)N)rSrr_)r;rSrr_)rXrHrHrIrb szFY5253Quarter._offsetcCs|jdko|jS)Nra)r`rbr)rXrHrHrIr szFY5253Quarter.isAnchoredc Csd}t|d}|j|}||kr||}tj|dt|d}|j|s`t |||f||}xB|D]0}|d|j kr|d7}|t |dd8}qnPqnWnt d}|||fS)a Roll `other` back to the most recent date that was on a fiscal year end. Return the date of that year-end, the number of full quarters elapsed between that year-end and other, and the remaining Timedelta since the most recent quarter-end. Parameters ---------- other : datetime or Timestamp Returns ------- tuple of prev_year_end : Timestamp giving most recent fiscal year end num_qtrs : int tdelta : Timedelta rNr)rura) r rRrbr get_weeksrerLrrrrur ) rXrYnum_qtrsrcrqtr_lensrtdeltaqlenrHrHrI_rollback_to_year s   zFY5253Quarter._rollback_to_yearc Cs|j}||\}}}|}||7}|jdkr>|jdkr>|d7}|d}|rd||j|7}||d8}||tdd}t|d|} | rtj|| dd}|S)Nrrar)rur) r`rprVrbrkr rrerL) rXrYr` prev_year_endrlrnresrrrmrtrHrHrIrpA s zFY5253Quarter.applycCs*dgd}||}|r&d||jd<|S)N rra)year_has_extra_weekrj)rXrretrurHrHrIrk] s   zFY5253Quarter.get_weekscCsNt|d}|j|}||j}||jd}|dksFt||dkS)Nr)45rx)r rTrRrbrrur)rXrrc next_year_endrqZ weeks_in_yearrHrHrIrug s   z!FY5253Quarter.year_has_extra_weekcCsj|jrt|sdS|j|r"dS||j}||}|}x*|D]"}tj||dd}||kr@dSq@WdS)NFTr)ru)rTrrbrrkrerL)rXrryrmcurrentZqtr_lenrHrHrIrr s    zFY5253Quarter.onOffsetcCs"|j}|j}dj|j||dS)Nz{prefix}-{suffix}-{qtr})r rqtr)rbrdrjrr)rXrr{rHrHrIr s zFY5253Quarter.rule_codecGs(|fttj|ddt|ddS)Nr)rj)dictr;rhr)rrirHrHrIr szFY5253Quarter._from_nameN)raFrrarar`)rrrrrrQrrrdrrbrrpr_rprkrurrrrrrHrHrHrIr:s(* /    c@s:eZdZdZdZeddgZejZe ddZ ddZ d S) r>z DateOffset for the Easter holiday using logic defined in dateutil. Right now uses the revised method which is valid in years 1583-4099. Tr`rTcCst|j}t|j|j|j}t||j}|j}|dkrJ||krJ|d8}n|dkrb||krb|d7}t|j|}t|j|j|j|j |j |j |j }|S)Nrra) rrrrrr rSrKr`rrrr)rXrYZcurrent_easterr`r*rHrHrIrp s&  z Easter.applycCs.|jrt|sdSt|j|j|jt|jkS)NF)rTrrrrrr)rXrrHrHrIr szEaster.onOffsetN) rrrrrQrrrrdr_rprrHrHrHrIr> s   cs4tjtjgkstfdd}djjd|_|S)NcsFy|j|jStk r@tdjt|jt|jdYnXdS)Nz*Invalid comparison between {cls} and {typ})rtyp)rr TypeErrorrrr)rXrY)r rHrIf s z_tick_comp..fz __{opname}__)opname)reqnerrr)r rrH)r rI _tick_comp s rc@seZdZeddZdZeddgZddd Ze e j Z e e j Ze e jZe e jZd d Zd d ZddZddZeddZeddZddZddZdS)rMi)ryZ undefinedr`rTraFcCst||||rtddS)Nz2Tick offset with `normalize=True` are not allowed.)rrdr)rXr`rTrHrHrIrd sz Tick.__init__cCst|tr@t|t|kr.t||j|jSt|j|jSnt|trR||Sy ||Stk rpt St k rt dj ||dYnXdS)Nz:the add operation between {self} and {other} will overflow)rXrY) rFrMrr`_delta_to_tickrrrprNotImplemented OverflowErrorr)rXrYrHrHrI__add__ s   z Tick.__add__cCsVt|tr8ddlm}y ||}Wntk r6dSXt|trN|j|jkSdSdS)Nr) to_offsetF)rFrpandas.tseries.frequenciesrrrMr)rXrYrrHrHrI__eq__ s     z Tick.__eq__cCs t|jS)N)hashr)rXrHrHrI__hash__ sz Tick.__hash__cCsVt|tr8ddlm}y ||}Wntk r6dSXt|trN|j|jkSdSdS)Nr)rT)rFrrrrrMr)rXrYrrHrHrI__ne__ s     z Tick.__ne__cCs |j|jS)N)r`rB)rXrHrHrIr! sz Tick.deltacCs t|jS)N)r r)rXrHrHrIr% sz Tick.nanoscCst|tr$||}|tkr t|St|ttjtfrBt ||St|t rV||j St|t |rxt ||j |j Stdjt |jddS)NzUnhandled type: {type_str})Ztype_str)rFr rrrrrNrOrrJrrrr`rrr)rXrYrZrHrHrIrp* s     z Tick.applycCsdS)NFrH)rXrHrHrIrC szTick.isAnchoredN)raF)rrrr rBrrrrdrrgt__gt__ge__ge__lt__lt__le__le__rrrrrrrrprrHrHrHrIrM s          rMcCs|jdkrxt|dddkrx|jdkr.t|jS|jd|j}|ddkrVt|dS|ddkrnt|dSt|Sn@t|}|ddkrt |dS|ddkrt |dSt |SdS)Nr nanosecondsiQiri@Bi) ryrPrxr"rur?r@rAr rBrCrD)rrxrrHrHrIrG s           rc@seZdZeddZdZdS)r"ra)rurN)rrrr rBrrHrHrHrIr"^ s c@seZdZeddZdZdS)r?ra)rvrN)rrrr rBrrHrHrHrIr?c s c@seZdZeddZdZdS)r@ra)rwTN)rrrr rBrrHrHrHrIr@h s c@seZdZeddZdZdS)rAra)rxr#N)rrrr rBrrHrHrHrIrAm s c@seZdZeddZdZdS)rBra) millisecondsrfN)rrrr rBrrHrHrHrIrBr s c@seZdZeddZdZdS)rCra)ryUN)rrrr rBrrHrHrHrIrCw s c@seZdZeddZdZdS)rDra)rreN)rrrr rBrrHrHrHrIrD| s ccsJddlm}||}t|}t|}|r>||s>||}n|rV||sV||}|dkrx||krx|jdkrxd}d}|dkr||d|}|dkr||d|}|}|jdkrx||kr|V||krP||}||krtdj |d|}qWnJxH||krD|V||krP||}||kr>tdj |d|}qWdS)a Generates a sequence of dates corresponding to the specified time offset. Similar to dateutil.rrule except uses pandas DateOffset objects to represent time increments. Parameters ---------- start : datetime (default None) end : datetime (default None) periods : int, (default None) offset : DateOffset, (default BDay()) Notes ----- * This method is faster for generating weekdays than dateutil.rrule * At least two of (start, end, periods) must be specified. * If both start and end are specified, the returned dates will satisfy start <= date <= end. Returns ------- dates : generator object r)rNraz&Offset {offset} did not increment date)rz&Offset {offset} did not decrement date) rrr!rrrr`rprr)rrZperiodsrrcurZ next_daterHrHrIgenerate_range sF           rcCsi|] }||jqSrH)r)r}rrHrHrIr sr)krrrr]rtypingrZdateutil.easterrZnumpyrNZpandas._libs.tslibsrrr r r r r rrFrrrerZpandas._libs.tslibs.offsetsrrrrrrrrrZ pandas.errorsrZpandas.util._decoratorsrrrZpandas.core.dtypes.genericrZpandas.core.dtypes.inferencer Zpandas.core.tools.datetimesr!__all__rJr_rErrrr#rr/r%r0rr+r)rr r"rr,r-r.r-r.r<rKr=r9rRr8r6r7r5r\r4r2r3r1r;r:r>rZ_TickrMrr"r?r@rArBrCrDr$r,r*r'r(r&rZprefix_mappingrHrHrHrIs$  4 ,     ?> sUN#!    `  i=>xKIF  ;   KQ3pR