

def _index_date(date, dates):
    '\n    Gets the index number of a date in a date index.\n\n    Works in-sample and will return one past the end of the dates since\n    prediction can start one out.\n\n    Currently used to validate prediction start dates.\n\n    If there dates are not of a fixed-frequency and date is not on the\n    existing dates, then a ValueError is raised.\n    '
    if isinstance(date, string_types):
        date = date_parser(date)
    try:
        if hasattr(dates, 'indexMap'):
            return dates.indexMap[date]
        else:
            date = dates.get_loc(date)
            try:
                len(date)
                return np.where(date)[0].item()
            except TypeError:
                return date
    except KeyError as err:
        freq = _infer_freq(dates)
        if (freq is None):
            raise ValueError(('There is no frequency for these dates and date %s is not in dates index. Try giving a date that is in the dates index or use an integer' % date))
        if (_idx_from_dates(dates[(- 1)], date, freq) == 1):
            return len(dates)
        raise ValueError(('date %s not in date index. Try giving a date that is in the dates index or use an integer' % date))

dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/tsa/base/datetools.py _index_date/original