[SciPy-user] scikits.timeseries

Dave Hirschfeld dave.hirschfeld@gmail....
Wed Dec 10 08:23:48 CST 2008

Pierre GM <pgmdevlist <at> gmail.com> writes:

> On Nov 27, 2008, at 11:23 AM, Robert Ferrell wrote:
> > 2. I've noticed that 'business frequency' includes holidays, and that
> > can create holes in what are actually complete data sets.  For
> > instance, Sep 01, 2008 was a holiday in the US (Labor Day).
> Yes, the moniker "business days" is a bit decepetive, as it refers  
> only to days that are not Saturday or Sunday. It'd be too tricky for  
> us to implement holidays, as it'd vary from one place to another (no  
> such things as Thanksgiving in Europe, for example...).

Hi Pierre & Matt,
I'm finding the timeseries package very useful but I've also run into the same
holidays issue as Robert. I was wondering if a solution of allowing the user
to specify the holidays (cf Excel networkdays function) would be feasible?

In the following example the user is able to change the function in the 
descriptor which would allow him/her to specify the holidays in their 
particular part of the world. I don't claim that this is the best way to do it, 
but I was wondering if such a scheme could be made to work in the wider context 
of the timeseries package?


from scikits.timeseries import Date, DateArray, date_array

class _isbusinessday(object):
    def __init__(self, func):
        assert callable(func)
        self.func = func
    def __get__(self, obj, objtype):
        return self.func(obj)
    def __set__(self, obj, func):
        assert callable(func)
        self.func = func

class BusinessDateArray(DateArray):
    isbusinessday = _isbusinessday(lambda x: x.weekday < 5)
    def __init__(self,*args,**kwargs):
        super(BusinessDateArray, self).__init__(*args,**kwargs)

dates = date_array(start_date=Date('D','01-Jan-2008'),length=100)
dates = BusinessDateArray(dates=dates)
print dates.isbusinessday

More information about the SciPy-user mailing list