@@ -541,10 +541,10 @@ calendars which account for local holidays and local weekend conventions.
541541 holidays = [' 2012-05-01' , datetime(2013 , 5 , 1 ), np.datetime64(' 2014-05-01' )]
542542 bday_egypt = CustomBusinessDay(holidays = holidays, weekmask = weekmask_egypt)
543543 dt = datetime(2013 , 4 , 30 )
544- print ( dt + 2 * bday_egypt)
544+ dt + 2 * bday_egypt
545545 dts = date_range(dt, periods = 5 , freq = bday_egypt).to_series()
546- print ( dts)
547- print ( Series(dts.weekday, dts).map(Series(' Mon Tue Wed Thu Fri Sat Sun' .split() )))
546+ dts
547+ Series(dts.weekday, dts).map(Series(' Mon Tue Wed Thu Fri Sat Sun' .split()))
548548
549549 As of v0.14 holiday calendars can be used to provide the list of holidays. See the
550550:ref: `holiday calendar<timeseries.holiday> ` section for more information.
@@ -553,8 +553,10 @@ As of v0.14 holiday calendars can be used to provide the list of holidays. See
553553
554554 from pandas.tseries.holiday import USFederalHolidayCalendar
555555 bday_us = CustomBusinessDay(calendar = USFederalHolidayCalendar())
556- dt = datetime(2014 , 1 , 17 ) # Friday before MLK Day
557- print (dt + bday_us) # Tuesday after MLK Day
556+ # Friday before MLK Day
557+ dt = datetime(2014 , 1 , 17 )
558+ # Tuesday after MLK Day (Monday is skipped because it's a holiday)
559+ dt + bday_us
558560
559561
560562 .. note ::
@@ -767,12 +769,36 @@ An example of how holidays and holiday calendars are defined:
767769 offset = DateOffset(weekday = MO(2 ))), # same as 2*Week(weekday=2)
768770 ]
769771 cal = ExampleCalendar()
770- datetime(2012 , 5 , 25 ) + CustomBusinessDay(calendar = cal)
771- cal.holidays(datetime(2012 , 1 , 1 ), datetime(2012 , 12 , 31 ))# holiday list
772- AbstractHolidayCalendar.start_date # default start date of range
773- AbstractHolidayCalendar.end_date # default end date of range
774- AbstractHolidayCalendar.start_date = datetime(2012 , 1 , 1 )# or Timestamp
775- AbstractHolidayCalendar.end_date = datetime(2012 , 12 , 31 )# or Timestamp
772+ cal.holidays(datetime(2012 , 1 , 1 ), datetime(2012 , 12 , 31 ))
773+
774+ Using this calendar, creating an index or doing offset arithmetic skips weekends
775+ and holidays (i.e., Memorial Day/July 4th).
776+
777+ .. ipython :: python
778+
779+ DatetimeIndex(start = ' 7/1/2012' , end = ' 7/10/2012' ,
780+ freq = CDay(calendar = cal)).to_pydatetime()
781+ offset = CustomBusinessDay(calendar = cal)
782+ datetime(2012 , 5 , 25 ) + offset
783+ datetime(2012 , 7 , 3 ) + offset
784+ datetime(2012 , 7 , 3 ) + 2 * offset
785+ datetime(2012 , 7 , 6 ) + offset
786+
787+ Ranges are defined by the ``start_date `` and ``end_date `` class attributes
788+ of ``AbstractHolidayCalendar ``. The defaults are below.
789+
790+ .. ipython :: python
791+
792+ AbstractHolidayCalendar.start_date
793+ AbstractHolidayCalendar.end_date
794+
795+ These dates can be overwritten by setting the attributes as
796+ datetime/Timestamp/string.
797+
798+ .. ipython :: python
799+
800+ AbstractHolidayCalendar.start_date = datetime(2012 , 1 , 1 )
801+ AbstractHolidayCalendar.end_date = datetime(2012 , 12 , 31 )
776802 cal.holidays()
777803
778804 Every calendar class is accessible by name using the ``get_calendar `` function
0 commit comments