示例#1
0
def fillforward(df):
    """
        Take a lower than day freq, and map it to business days.
        This is to make mapping to a daily chart easy and helps handle
        business days that vacations.
    """
    return df.asfreq(datetools.BDay(), method='pad')
示例#2
0
import re
import datetime
from pandas import datetools as pandas_datetools
import numpy as np
from statsmodels.compatnp.py3k import asstr

#NOTE: All of these frequencies assume end of period (except wrt time)
try:
    from pandas.tseries.frequencies import get_offset
    class _freq_to_pandas_class(object):
        # being lazy, don't want to replace dictionary below
        def __getitem__(self, key):
            return get_offset(key)
    _freq_to_pandas = _freq_to_pandas_class()
except ImportError, err:
    _freq_to_pandas = {'B' : pandas_datetools.BDay(1),
                       'D' : pandas_datetools.day,
                       'W' : pandas_datetools.Week(weekday=6),
                       'M' : pandas_datetools.monthEnd,
                       'A' : pandas_datetools.yearEnd,
                       'Q' : pandas_datetools.quarterEnd}

def _index_date(date, dates):
    """
    Gets the index number of a date in a date index.

    Works in-sample and will return one past the end of the dates since
    prediction can start one out.

    Currently used to validate prediction start dates.
示例#3
0
from pandas import datetools as pandas_datetools
import numpy as np

#NOTE: All of these frequencies assume end of period (except wrt time)
try:
    from pandas.tseries.frequencies import get_offset

    class _freq_to_pandas_class(object):
        # being lazy, don't want to replace dictionary below
        def __getitem__(self, key):
            return get_offset(key)

    _freq_to_pandas = _freq_to_pandas_class()
except ImportError, err:
    _freq_to_pandas = {
        'B': pandas_datetools.BDay(1),
        'D': pandas_datetools.day,
        'W': pandas_datetools.Week(weekday=6),
        'M': pandas_datetools.monthEnd,
        'A': pandas_datetools.yearEnd,
        'Q': pandas_datetools.quarterEnd
    }


def _index_date(date, dates):
    """
    Gets the index number of a date in a date index.

    Works in-sample and will return one past the end of the dates since
    prediction can start one out.