コード例 #1
0
def get_date_range(df, n_out):
    '''
        Takes in the processed dataset and returns a list of n_out
        business days, beginning from tomorrow (given the next 5 days
        of prediction
        '''
    start = (pd.Timestamp(df.index.max()) + relativedelta(days=1))
    date = set()
    for i in range(
            n_out + 1
    ):  # add an extra day to the set to allow for duplicates caused by Sat and Sun - then remove
        date.add(start + pd.tseries.offsets.BusinessDay(n=i))

    dates = list(date)
    dates.sort()

    return dates[:
                 5]  # in case 6 are returned - n_out + 1 is necessary for weekly duplicating issue.
コード例 #2
0
    def test_isinstance_default(self):
        from datetime import date
        to_check = []
        to_check.append(date(1999, 1, 1))
        to_check.append(date.today())
        date.set(2001, 1, 2)
        to_check.append(date.today())
        date.add(2001, 1, 3)
        to_check.append(date.today())
        to_check.append(date.today())
        date.set(date(2001, 1, 4))
        to_check.append(date.today())
        date.add(date(2001, 1, 5))
        to_check.append(date.today())
        to_check.append(date.today())
        date.set(d(2001, 1, 4))
        to_check.append(date.today())
        date.add(d(2001, 1, 5))
        to_check.append(date.today())
        to_check.append(date.today())

        for inst in to_check:
            self.failIf(isinstance(inst, date), inst)
            self.failIf(inst.__class__ is date, inst)
            self.failUnless(isinstance(inst, d), inst)
            self.failUnless(inst.__class__ is d, inst)
コード例 #3
0
 def test_add_date_supplied(self):
     from datetime import date
     date.add(d(2001, 1, 2))
     date.add(date(2001, 1, 3))
     compare(date.today(), d(2001, 1, 2))
     compare(date.today(), d(2001, 1, 3))