def _idx_from_dates(d1, d2, freq):
    """
    Returns an index offset from datetimes d1 and d2. d1 is expected to be the
    last date in a date series and d2 is the out of sample date.

    Notes
    -----
    Rounds down the index if the end date is before the next date at freq.
    Does not check the start date to see whether it is on the offest but
    assumes that it is.
    """
    from pandas import DatetimeIndex
    return len(DatetimeIndex(start=d1, end=d2,
                             freq = _freq_to_pandas[freq])) - 1
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/tsa/base/datetools.py/_idx_from_dates/original