本文整理汇总了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
示例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)
示例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,
)
示例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')
示例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,
)
示例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)
示例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,
)