# Buggy code
def get_loc(self, key, method=None, tolerance=None):
    """
    Get integer location for requested label

    Parameters
    ----------
    key : label
    method : {None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}, optional
        * default: exact matches only.
        * pad / ffill: find the PREVIOUS index value if no exact match.
        * backfill / bfill: use NEXT index value if no exact match
        * nearest: use the NEAREST index value if no exact match. Tied
          distances are broken by preferring the larger index value.
    tolerance : optional
        Maximum distance from index value for inexact matches. The value of
        the index at the matching location most satisfy the equation
        ``abs(index[loc] - key) <= tolerance``.

        .. versionadded:: 0.17.0

    Returns
    -------
    loc : int if unique index, possibly slice or mask if not
    """
    if method is None:
        if tolerance is not None:
            raise ValueError(
                "tolerance argument only valid if using pad, "
                "backfill or nearest lookups"
            )
        return self._engine.get_loc(_values_from_object(key))

    indexer = self.get_indexer([key], method=method, tolerance=tolerance)
    if indexer.ndim > 1 or indexer.size > 1:
        raise TypeError("get_loc requires scalar valued input")
    loc = indexer.item()
    if loc == -1:
        raise KeyError(key)
    return loc


# Traceback (ValueError)
series length = 5
series length = 999999
series length = 1000000
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
File "/home/nekobon/.env_exp/lib/python3.4/site-packages/pandas/core/indexing.py", line 114, in __setitem__
indexer = self._get_setitem_indexer(key)
File "/home/nekobon/.env_exp/lib/python3.4/site-packages/pandas/core/indexing.py", line 109, in _get_setitem_indexer
return self._convert_to_indexer(key, is_setter=True)
File "/home/nekobon/.env_exp/lib/python3.4/site-packages/pandas/core/indexing.py", line 1042, in _convert_to_indexer
return labels.get_loc(obj)
File "/home/nekobon/.env_exp/lib/python3.4/site-packages/pandas/core/index.py", line 1692, in get_loc
return self._engine.get_loc(_values_from_object(key))
File "pandas/index.pyx", line 137, in pandas.index.IndexEngine.get_loc (pandas/index.c:3979)
File "pandas/index.pyx", line 145, in pandas.index.IndexEngine.get_loc (pandas/index.c:3680)
File "pandas/index.pyx", line 464, in pandas.index._bin_search (pandas/index.c:9124)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

# Fixed code
def get_loc(self, key, method=None, tolerance=None):
    """
    Get integer location for requested label

    Parameters
    ----------
    key : label
    method : {None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}, optional
        * default: exact matches only.
        * pad / ffill: find the PREVIOUS index value if no exact match.
        * backfill / bfill: use NEXT index value if no exact match
        * nearest: use the NEAREST index value if no exact match. Tied
          distances are broken by preferring the larger index value.
    tolerance : optional
        Maximum distance from index value for inexact matches. The value of
        the index at the matching location most satisfy the equation
        ``abs(index[loc] - key) <= tolerance``.

        .. versionadded:: 0.17.0

    Returns
    -------
    loc : int if unique index, possibly slice or mask if not
    """
    if method is None:
        if tolerance is not None:
            raise ValueError(
                "tolerance argument only valid if using pad, "
                "backfill or nearest lookups"
            )
        key = _values_from_object(key)
        return self._engine.get_loc(key)

    indexer = self.get_indexer([key], method=method, tolerance=tolerance)
    if indexer.ndim > 1 or indexer.size > 1:
        raise TypeError("get_loc requires scalar valued input")
    loc = indexer.item()
    if loc == -1:
        raise KeyError(key)
    return loc