当前位置: 首页>>代码示例>>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;未经允许,请勿转载。