本文簡要介紹 python 語言中 numpy.busdaycalendar
的用法。
用法:
class numpy.busdaycalendar(weekmask='1111100', holidays=None)
一個工作日日曆對象,可有效存儲定義 busday 係列函數的有效日期的信息。
默認有效日期為周一至周五 (“business days”)。 busdaycalendar 對象可以指定為任何一組每周有效日期,以及一個始終無效的可選 “holiday” 日期。
一旦創建了 busdaycalendar 對象,就不能修改星期掩碼和假期。
- weekmask: str 或 數組 的 bool,可選
一個 seven-element 數組,指示周一到周日中的哪一天是有效日期。可以指定為 length-seven 列表或數組,如 [1,1,1,1,1,0,0]; length-seven 字符串,例如 ‘1111100’;或類似“Mon Tue Wed Thu Fri”的字符串,由工作日的 3 個字符縮寫組成,可選用空格分隔。有效縮寫為: Mon Tue Wed Thu Fri Sat Sun
- holidays: 類似 datetime64[D] 的數組,可選
被視為無效日期的日期數組,無論它們屬於哪個工作日。假期日期可以按任何順序指定,並且 NaT (not-a-time) 日期將被忽略。該列表以標準化形式保存,適合快速計算有效天數。
- out: 公曆日曆
包含指定的星期掩碼和假期值的工作日日曆對象。
參數:
返回:
例子:
>>> # Some important days in July ... bdd = np.busdaycalendar( ... holidays=['2011-07-01', '2011-07-04', '2011-07-17']) >>> # Default is Monday to Friday weekdays ... bdd.weekmask array([ True, True, True, True, True, False, False]) >>> # Any holidays already on the weekend are removed ... bdd.holidays array(['2011-07-01', '2011-07-04'], dtype='datetime64[D]')
相關用法
- Python numpy busday_offset用法及代碼示例
- Python numpy busday_count用法及代碼示例
- Python numpy broadcast用法及代碼示例
- Python numpy byte_bounds用法及代碼示例
- Python numpy block用法及代碼示例
- Python numpy broadcast.nd用法及代碼示例
- Python numpy base_repr用法及代碼示例
- Python numpy bartlett用法及代碼示例
- Python numpy broadcast.size用法及代碼示例
- Python numpy blackman用法及代碼示例
- Python numpy broadcast.reset用法及代碼示例
- Python numpy broadcast_shapes用法及代碼示例
- Python numpy bitwise_xor用法及代碼示例
- Python numpy binary_repr用法及代碼示例
- Python numpy bitwise_and用法及代碼示例
- Python numpy broadcast.numiter用法及代碼示例
- Python numpy broadcast.iters用法及代碼示例
- Python numpy broadcast_to用法及代碼示例
- Python numpy broadcast_arrays用法及代碼示例
- Python numpy broadcast.ndim用法及代碼示例
- Python numpy bmat用法及代碼示例
- Python numpy bincount用法及代碼示例
- Python numpy broadcast.index用法及代碼示例
- Python numpy bitwise_or用法及代碼示例
- Python numpy RandomState.standard_exponential用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.busdaycalendar。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。