當前位置: 首頁>>代碼示例>>Python>>正文


Python numpy.is_busday方法代碼示例

本文整理匯總了Python中numpy.is_busday方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.is_busday方法的具體用法?Python numpy.is_busday怎麽用?Python numpy.is_busday使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy的用法示例。


在下文中一共展示了numpy.is_busday方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_datetime_is_busday

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import is_busday [as 別名]
def test_datetime_is_busday(self):
        holidays = ['2011-01-01', '2011-10-10', '2011-11-11', '2011-11-24',
                    '2011-12-25', '2011-05-30', '2011-02-21', '2011-01-17',
                    '2011-12-26', '2012-01-02', '2011-02-21', '2011-05-30',
                    '2011-07-01', '2011-07-04', '2011-09-05', '2011-10-10',
                    'NaT']
        bdd = np.busdaycalendar(weekmask='1111100', holidays=holidays)

        # Weekend/weekday tests
        assert_equal(np.is_busday('2011-01-01'), False)
        assert_equal(np.is_busday('2011-01-02'), False)
        assert_equal(np.is_busday('2011-01-03'), True)

        # All the holidays are not business days
        assert_equal(np.is_busday(holidays, busdaycal=bdd),
                     np.zeros(len(holidays), dtype='?')) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:test_datetime.py

示例2: test_datetime_is_busday

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import is_busday [as 別名]
def test_datetime_is_busday(self):
        holidays=['2011-01-01', '2011-10-10', '2011-11-11', '2011-11-24',
                  '2011-12-25', '2011-05-30', '2011-02-21', '2011-01-17',
                  '2011-12-26', '2012-01-02', '2011-02-21', '2011-05-30',
                  '2011-07-01', '2011-07-04', '2011-09-05', '2011-10-10',
                  'NaT']
        bdd = np.busdaycalendar(weekmask='1111100', holidays=holidays)

        # Weekend/weekday tests
        assert_equal(np.is_busday('2011-01-01'), False)
        assert_equal(np.is_busday('2011-01-02'), False)
        assert_equal(np.is_busday('2011-01-03'), True)

        # All the holidays are not business days
        assert_equal(np.is_busday(holidays, busdaycal=bdd),
                     np.zeros(len(holidays), dtype='?')) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:test_datetime.py

示例3: is_business_day

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import is_busday [as 別名]
def is_business_day(dates: DateOrDates, calendars: Union[str, Tuple[str, ...]] = (), week_mask: Optional[str] = None)\
        -> Union[bool, Tuple[bool]]:
    """
    Determine whether each date in dates is a business day

    :param dates: The input date or dates
    :param calendars: Calendars to use for holidays
    :param week_mask: Which days are considered weekends (defaults to Saturday and Sunday)
    :return: True/False if dates is a single date. A tuple indicating True/False for each date if dates is an iterable

    **Examples**

    >>> import datetime as dt
    >>> is_business_day(dt.date.today())
    >>> is_business_day(dt.date(2019, 7, 4), calendars=('NYSE',))
    """
    calendar = GsCalendar.get(calendars)
    res = np.is_busday(dates, busdaycal=calendar.business_day_calendar(week_mask))
    return tuple(res) if isinstance(res, np.ndarray) else res 
開發者ID:goldmansachs,項目名稱:gs-quant,代碼行數:21,代碼來源:date.py

示例4: onOffset

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import is_busday [as 別名]
def onOffset(self, dt):
        if self.normalize and not _is_normalized(dt):
            return False
        day64 = _to_dt64(dt, 'datetime64[D]')
        return np.is_busday(day64, busdaycal=self.calendar) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:offsets.py

示例5: onOffset

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import is_busday [as 別名]
def onOffset(self, dt):
        day64 = self._to_dt64(dt).astype('datetime64[D]')
        return np.is_busday(day64, busdaycal=self.busdaycalendar) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:5,代碼來源:offsets.py

示例6: test_is_busday

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import is_busday [as 別名]
def test_is_busday(self):
        with pytest.raises(TypeError):
            np.is_busday(self.q)


# These functions always worked; ensure they do not regress.
# Note that they are *not* wrapped so no need to check coverage. 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:9,代碼來源:test_quantity_non_ufuncs.py

示例7: is_busday

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import is_busday [as 別名]
def is_busday(dates, weekmask=None, holidays=None, busdaycal=None, out=None):
    """
    is_busday(dates, weekmask='1111100', holidays=None, busdaycal=None, out=None)

    Calculates which of the given dates are valid days, and which are not.

    .. versionadded:: 1.7.0

    Parameters
    ----------
    dates : array_like of datetime64[D]
        The array of dates to process.
    weekmask : str or array_like of bool, optional
        A seven-element array indicating which of Monday through Sunday are
        valid days. May be specified as a length-seven list or array, like
        [1,1,1,1,1,0,0]; a length-seven string, like '1111100'; or a string
        like "Mon Tue Wed Thu Fri", made up of 3-character abbreviations for
        weekdays, optionally separated by white space. Valid abbreviations
        are: Mon Tue Wed Thu Fri Sat Sun
    holidays : array_like of datetime64[D], optional
        An array of dates to consider as invalid dates.  They may be
        specified in any order, and NaT (not-a-time) dates are ignored.
        This list is saved in a normalized form that is suited for
        fast calculations of valid days.
    busdaycal : busdaycalendar, optional
        A `busdaycalendar` object which specifies the valid days. If this
        parameter is provided, neither weekmask nor holidays may be
        provided.
    out : array of bool, optional
        If provided, this array is filled with the result.

    Returns
    -------
    out : array of bool
        An array with the same shape as ``dates``, containing True for
        each valid day, and False for each invalid day.

    See Also
    --------
    busdaycalendar: An object that specifies a custom set of valid days.
    busday_offset : Applies an offset counted in valid days.
    busday_count : Counts how many valid days are in a half-open date range.

    Examples
    --------
    >>> # The weekdays are Friday, Saturday, and Monday
    ... np.is_busday(['2011-07-01', '2011-07-02', '2011-07-18'],
    ...                 holidays=['2011-07-01', '2011-07-04', '2011-07-17'])
    array([False, False,  True], dtype='bool')
    """
    return (dates, weekmask, holidays, out) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:53,代碼來源:multiarray.py


注:本文中的numpy.is_busday方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。