Numpy 的 busdaycalendar
對象對用戶提供的被視為有效的日期進行編碼。請注意,busday 代表工作日,但我們可以通過參數指定"business" 日。
警告
Busdaycalendar 對象一旦創建,就無法更改。
參數
1.weekmask
| string
或array-like
或boolean
| optional
一周中被視為有效的日子。您可以指定長度為 7 的字符串,其中 0 代表無效,1 代表有效工作日,從周一到周日。例如,"1111100"
意味著周末(周六和周日)為無效日期。此外,您還可以使用 three-character 縮寫,例如:
Mon Tue Wed Thu Fri Sat Sun
例如,"Mon Wed Fri"
表示隻有星期一、星期三和星期五是有效日期,所有其他工作日均無效。
或者,您可以提供大小為 7 的布爾值數組,其中 True 表示相應的工作日有效,否則為 False。例如,[True,True,True,True,True,False,False]
再次意味著周末是無效日期。
默認情況下, weekmask="1111100"
,即有效工作日為周一至周五(含周一至周五)。
2. holidays
| datetime
的array-like
| optional
被視為無效日期的日期時間數組。日期時間本質上是格式化的字符串,如下所示:
"2020-05-25"
返回值
對提供的參數進行編碼的 busdaycalendar
對象。
例子
基本用法
np.busdaycalendar("1111110", ["2020-12-25", "2020-12-26", "2020-12-27"])
array([ True, True, False])
在這裏,我們將三個日期設置為無效日期,並將周日的所有日期設置為無效日期。
相關用法
- Python NumPy busday_count方法用法及代碼示例
- Python NumPy busday_offset方法用法及代碼示例
- Python MongoDB bulk_write()用法及代碼示例
- Python binascii.crc32用法及代碼示例
- Python bytes.isupper用法及代碼示例
- Python base64.b64decode()用法及代碼示例
- Python bokeh.plotting.figure.asterisk()用法及代碼示例
- Python bytes.zfill用法及代碼示例
- Python binary轉string用法及代碼示例
- Python base64.b32decode()用法及代碼示例
- Python bytes.expandtabs用法及代碼示例
- Python bytearray()用法及代碼示例
- Python bokeh.plotting.figure.annular_wedge()用法及代碼示例
- Python NumPy base屬性用法及代碼示例
- Python Pandas bdate_range方法用法及代碼示例
- Python bytes.isalpha用法及代碼示例
- Python base64.b85encode()用法及代碼示例
- Python base64.b64encode()用法及代碼示例
- Python bokeh.plotting.figure.circle()用法及代碼示例
- Python bytes.hex用法及代碼示例
- Python bool()用法及代碼示例
- Python bz2.decompress(s)用法及代碼示例
- Python bokeh.plotting.figure.circle_cross()用法及代碼示例
- Python bokeh.plotting.figure.bezier()用法及代碼示例
- Python bokeh.plotting.figure.diamond()用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | busdaycalendar object。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。