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


Python offsets.CustomBusinessDay方法代碼示例

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


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

示例1: datefmt

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import CustomBusinessDay [as 別名]
def datefmt(xdate, cal=None):
    from pandas.tseries.holiday import AbstractHolidayCalendar, Holiday, nearest_workday, \
        USMartinLutherKingJr, USPresidentsDay, GoodFriday, USMemorialDay, \
        USLaborDay, USThanksgivingDay
    from pandas.tseries.offsets import CustomBusinessDay
    class USTradingCalendar(AbstractHolidayCalendar):
        rules = [
            Holiday('NewYearsDay', month=1, day=1, observance=nearest_workday),
            USMartinLutherKingJr,
            USPresidentsDay,
            GoodFriday,
            USMemorialDay,
            Holiday('USIndependenceDay', month=7, day=4, observance=nearest_workday),
            USLaborDay,
            USThanksgivingDay,
            Holiday('Christmas', month=12, day=25, observance=nearest_workday)
        ]
    if cal == None: cal = USTradingCalendar()
    def mydate(x,pos):
        #print((x,pos))
        val = int(x + 0.5)
        if val < 0: return (xdate[0].to_pydatetime() - CustomBusinessDay(-val, calendar=cal)).strftime('%Y-%m-%d')
        elif val >= len(xdate): return (xdate[-1].to_pydatetime() + CustomBusinessDay(val - len(xdate) + 1, calendar=cal)).strftime('%Y-%m-%d')
        else: return xdate[val].strftime('%Y-%m-%d')
    return mydate 
開發者ID:GregoryMorse,項目名稱:trendln,代碼行數:27,代碼來源:__init__.py

示例2: test_custom_business_day_freq

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import CustomBusinessDay [as 別名]
def test_custom_business_day_freq(self):
        # GH7222
        from pandas.tseries.offsets import CustomBusinessDay
        s = Series(range(100, 121), index=pd.bdate_range(
            start='2014-05-01', end='2014-06-01',
            freq=CustomBusinessDay(holidays=['2014-05-26'])))

        _check_plot_works(s.plot) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test_series.py

示例3: day

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import CustomBusinessDay [as 別名]
def day(self):
        return CustomBusinessDay(
            holidays=self.adhoc_holidays,
            calendar=self.regular_holidays,
            weekmask=self.weekmask,
        ) 
開發者ID:quantopian,項目名稱:trading_calendars,代碼行數:8,代碼來源:trading_calendar.py

示例4: day

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import CustomBusinessDay [as 別名]
def day(self):
        return CustomBusinessDay(weekmask='Mon Tue Wed Thu Fri Sat Sun') 
開發者ID:nerddan,項目名稱:zipline-bitmex,代碼行數:4,代碼來源:bitmex_calendar.py

示例5: day

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import CustomBusinessDay [as 別名]
def day(self):
        return CustomBusinessDay(
            holidays=self.adhoc_holidays,
            calendar=self.regular_holidays,
        ) 
開發者ID:enigmampc,項目名稱:catalyst,代碼行數:7,代碼來源:trading_calendar.py

示例6: _get_custom_bd

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import CustomBusinessDay [as 別名]
def _get_custom_bd(exchange):
    from pandas.tseries.offsets import CustomBusinessDay
    calendar = GsCalendar.get(exchange).business_day_calendar()
    return CustomBusinessDay(calendar=calendar) 
開發者ID:goldmansachs,項目名稱:gs-quant,代碼行數:6,代碼來源:measures.py

示例7: holidays

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import CustomBusinessDay [as 別名]
def holidays(self):
        """
        Returns the complete CustomBusinessDay object of holidays that can be used in any Pandas function that take
        that input.

        :return: CustomBusinessDay object of holidays
        """
        return CustomBusinessDay(
            holidays=self.adhoc_holidays,
            calendar=self.regular_holidays,
            weekmask=self.weekmask,
        ) 
開發者ID:rsheftel,項目名稱:pandas_market_calendars,代碼行數:14,代碼來源:market_calendar.py


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