@@ -129,10 +129,10 @@ class from pandas.tseries.offsets
129
129
computes offset from date
130
130
observance: function
131
131
computes when holiday is given a pandas Timestamp
132
- days_of_week:
132
+ days_of_week:
133
133
provide a tuple of days e.g (0,1,2,3,) for Monday Through Thursday
134
134
Monday=0,..,Sunday=6
135
-
135
+
136
136
Examples
137
137
--------
138
138
>>> from pandas.tseries.holiday import Holiday, nearest_workday
@@ -148,13 +148,13 @@ class from pandas.tseries.offsets
148
148
>>> July3rd = Holiday('July 3rd', month=7, day=3,
149
149
days_of_week=(0, 1, 2, 3))
150
150
"""
151
- self .name = name
152
- self .year = year
153
- self .month = month
154
- self .day = day
155
- self .offset = offset
151
+ self .name = name
152
+ self .year = year
153
+ self .month = month
154
+ self .day = day
155
+ self .offset = offset
156
156
self .start_date = start_date
157
- self .end_date = end_date
157
+ self .end_date = end_date
158
158
self .observance = observance
159
159
assert (days_of_week is None or type (days_of_week ) == tuple )
160
160
self .days_of_week = days_of_week
@@ -200,14 +200,14 @@ def dates(self, start_date, end_date, return_name=False):
200
200
end_date = self .end_date
201
201
202
202
start_date = Timestamp (start_date )
203
- end_date = Timestamp (end_date )
203
+ end_date = Timestamp (end_date )
204
204
205
205
year_offset = DateOffset (years = 1 )
206
206
base_date = Timestamp (datetime (start_date .year , self .month , self .day ))
207
207
dates = DatetimeIndex (start = base_date , end = end_date , freq = year_offset )
208
208
holiday_dates = self ._apply_rule (dates )
209
209
if self .days_of_week is not None :
210
- holiday_dates = list (filter (lambda x : x is not None and
210
+ holiday_dates = list (filter (lambda x : x is not None and
211
211
x .dayofweek in self .days_of_week ,
212
212
holiday_dates ))
213
213
else :
@@ -235,9 +235,9 @@ def _apply_rule(self, dates):
235
235
236
236
if self .offset is not None :
237
237
if not isinstance (self .offset , list ):
238
- offsets = [self .offset ]
238
+ offsets = [self .offset ]
239
239
else :
240
- offsets = self .offset
240
+ offsets = self .offset
241
241
for offset in offsets :
242
242
dates = list (map (lambda d : d + offset , dates ))
243
243
return dates
@@ -275,7 +275,7 @@ class AbstractHolidayCalendar(object):
275
275
__metaclass__ = HolidayCalendarMetaClass
276
276
rules = []
277
277
start_date = Timestamp (datetime (1970 , 1 , 1 ))
278
- end_date = Timestamp (datetime (2030 , 12 , 31 ))
278
+ end_date = Timestamp (datetime (2030 , 12 , 31 ))
279
279
_holiday_cache = None
280
280
281
281
def __init__ (self , name = None , rules = None ):
@@ -315,7 +315,7 @@ def holidays(self, start=None, end=None, return_name=False):
315
315
DatetimeIndex of holidays
316
316
"""
317
317
if self .rules is None :
318
- raise Exception ('Holiday Calendar %s does not have any ' \
318
+ raise Exception ('Holiday Calendar %s does not have any '
319
319
'rules specified' % self .name )
320
320
321
321
if start is None :
@@ -325,7 +325,7 @@ def holidays(self, start=None, end=None, return_name=False):
325
325
end = AbstractHolidayCalendar .end_date
326
326
327
327
start = Timestamp (start )
328
- end = Timestamp (end )
328
+ end = Timestamp (end )
329
329
330
330
holidays = None
331
331
# If we don't have a cache or the dates are outside the prior cache, we get them again
@@ -359,7 +359,7 @@ def _cache(self, values):
359
359
@staticmethod
360
360
def merge_class (base , other ):
361
361
"""
362
- Merge holiday calendars together. The base calendar
362
+ Merge holiday calendars together. The base calendar
363
363
will take precedence to other. The merge will be done
364
364
based on each holiday's name.
365
365
@@ -384,7 +384,7 @@ def merge_class(base, other):
384
384
385
385
if not isinstance (base , list ):
386
386
base = [base ]
387
- base_holidays = dict ([ (holiday .name ,holiday ) for holiday in base ])
387
+ base_holidays = dict ([(holiday .name , holiday ) for holiday in base ])
388
388
389
389
other_holidays .update (base_holidays )
390
390
return list (other_holidays .values ())
@@ -401,30 +401,29 @@ def merge(self, other, inplace=False):
401
401
inplace : bool (default=False)
402
402
If True set rule_table to holidays, else return array of Holidays
403
403
"""
404
- holidays = self .merge_class (self , other )
404
+ holidays = self .merge_class (self , other )
405
405
if inplace :
406
406
self .rules = holidays
407
407
else :
408
408
return holidays
409
409
410
- USMemorialDay = Holiday ('MemorialDay' , month = 5 , day = 24 ,
411
- offset = DateOffset (weekday = MO (1 )))
412
- USLaborDay = Holiday ('Labor Day' , month = 9 , day = 1 ,
413
- offset = DateOffset (weekday = MO (1 )))
414
- USColumbusDay = Holiday ('Columbus Day' , month = 10 , day = 1 ,
415
- offset = DateOffset (weekday = MO (2 )))
410
+ USMemorialDay = Holiday ('MemorialDay' , month = 5 , day = 24 ,
411
+ offset = DateOffset (weekday = MO (1 )))
412
+ USLaborDay = Holiday ('Labor Day' , month = 9 , day = 1 ,
413
+ offset = DateOffset (weekday = MO (1 )))
414
+ USColumbusDay = Holiday ('Columbus Day' , month = 10 , day = 1 ,
415
+ offset = DateOffset (weekday = MO (2 )))
416
416
USThanksgivingDay = Holiday ('Thanksgiving' , month = 11 , day = 1 ,
417
417
offset = DateOffset (weekday = TH (4 )))
418
418
USMartinLutherKingJr = Holiday ('Dr. Martin Luther King Jr.' , month = 1 , day = 1 ,
419
419
offset = DateOffset (weekday = MO (3 )))
420
- USPresidentsDay = Holiday ('President' 's Day' , month = 2 , day = 1 ,
421
- offset = DateOffset (weekday = MO (3 )))
420
+ USPresidentsDay = Holiday ('President' 's Day' , month = 2 , day = 1 ,
421
+ offset = DateOffset (weekday = MO (3 )))
422
422
GoodFriday = Holiday ("Good Friday" , month = 1 , day = 1 , offset = [Easter (), Day (- 2 )])
423
423
424
424
EasterMonday = Holiday ("Easter Monday" , month = 1 , day = 1 , offset = [Easter (), Day (1 )])
425
425
426
426
427
-
428
427
class USFederalHolidayCalendar (AbstractHolidayCalendar ):
429
428
"""
430
429
US Federal Government Holiday Calendar based on rules specified
0 commit comments