'Get the location of a specific key in an index
Parameters
key : label
The key for which to find the location
base_index : pd.Index, optional
Optionally the base index to search. If None, the model\'s index is
searched.
Returns
loc : int
The location of the key
index : pd.Index
The index including the key; this is a copy of the original index
unless the index had to be expanded to accomodate `key`.
index_was_expanded : bool
Whether or not the index was expanded to accomodate `key`.
Notes
If `key` is past the end of of the given index, and the index is either
an Int64Index or a date index, this function extends the index up to
and including key, and then returns the location in the new index.'

def _get_index_loc(self, key, base_index=None):

    if (base_index is None):
        base_index = self._index
    index = base_index
    date_index = isinstance(base_index, (PeriodIndex, DatetimeIndex))
    index_class = type(base_index)
    nobs = len(index)
    if (isinstance(index, Int64Index) and (not date_index) and isinstance(key, (int, long, np.integer))):
        if ((key < 0) and ((- key) <= nobs)):
            key = (nobs + key)
        elif (key > base_index[(-1)]):
            index = Int64Index(np.arange(base_index[0], int((key + 1))))
    if date_index:
        if isinstance(key, (int, long, np.integer)):
            if ((key < 0) and ((- key) < nobs)):
                key = index[(nobs + key)]
            elif (key > (len(base_index) - 1)):
                index = index_class(start=base_index[0], periods=int((key + 1)), freq=base_index.freq)
                key = index[(-1)]
            else:
                key = index[key]
        else:
            if (index_class is PeriodIndex):
                date_key = Period(key, freq=base_index.freq)
            else:
                date_key = Timestamp(key)
            if (date_key > base_index[(-1)]):
                index = index_class(start=base_index[0], end=date_key, freq=base_index.freq)
                if (not (index[(-1)] == date_key)):
                    index = index_class(start=base_index[0], periods=(len(index) + 1), freq=base_index.freq)
    loc = index.get_loc(key)
    index_was_expanded = (index is not base_index)
    if (not index_was_expanded):
        index = index.copy()
    if isinstance(loc, slice):
        end = loc.stop
    else:
        end = loc
    return (loc, index[:(end + 1)], index_was_expanded)
