本文整理匯總了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,
)