原文:https://docs.scipy.org/doc/numpy/reference/generated/numpy.busday_offset.html
校对:(虚位以待)
numpy.
busday_offset
(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None)首先根据roll
规则将日期调整为有效日期,然后将偏移量应用于在有效天计算的给定日期。
版本1.7.0中的新功能。
参数: | 日期:array_like of datetime64 [D]
offsets:array_like of int
roll:{'raise','nat','forward','following','backward','preceding','modifiedfollowing','modifiedpreceding'
weekmask:str或array_like of bool,可选
节假日:array_like of datetime64 [D],可选
busdaycal:busdaycalendar,可选
out:datetime64的数组[D],可选
|
---|---|
返回: | out:datetime64的数组[D]
|
也可以看看
busdaycalendar
is_busday
busday_count
例子
>>> # First business day in October 2011 (not accounting for holidays)
... np.busday_offset('2011-10', 0, roll='forward')
numpy.datetime64('2011-10-03','D')
>>> # Last business day in February 2012 (not accounting for holidays)
... np.busday_offset('2012-03', -1, roll='forward')
numpy.datetime64('2012-02-29','D')
>>> # Third Wednesday in January 2011
... np.busday_offset('2011-01', 2, roll='forward', weekmask='Wed')
numpy.datetime64('2011-01-19','D')
>>> # 2012 Mother's Day in Canada and the U.S.
... np.busday_offset('2012-05', 1, roll='forward', weekmask='Sun')
numpy.datetime64('2012-05-13','D')
>>> # First business day on or after a date
... np.busday_offset('2011-03-20', 0, roll='forward')
numpy.datetime64('2011-03-21','D')
>>> np.busday_offset('2011-03-22', 0, roll='forward')
numpy.datetime64('2011-03-22','D')
>>> # First business day after a date
... np.busday_offset('2011-03-20', 1, roll='backward')
numpy.datetime64('2011-03-21','D')
>>> np.busday_offset('2011-03-22', 1, roll='backward')
numpy.datetime64('2011-03-23','D')