# Buggy code
def _wrap_result(self, result, use_codes=True, name=None):
    # for category, we do the stuff on the categories, so blow it up
    # to the full series again
    # But for some operations, we have to do the stuff on the full values,
    # so make it possible to skip this step as the method already did this
    # before the transformation...
    if use_codes and self._is_categorical:
        result = take_1d(result, self._orig.cat.codes)

    # leave as it is to keep extract and get_dummies results
    # can be merged to _wrap_result_expand in v0.17
    from pandas.core.series import Series
    from pandas.core.frame import DataFrame
    from pandas.core.index import Index

    if not hasattr(result, "ndim"):
        return result
    name = name or getattr(result, "name", None) or self._orig.name

    if result.ndim == 1:
        if isinstance(self._orig, Index):
            # if result is a boolean np.array, return the np.array
            # instead of wrapping it into a boolean Index (GH 8875)
            if is_bool_dtype(result):
                return result
            return Index(result, name=name)
        return Series(result, index=self._orig.index, name=name)
    else:
        assert result.ndim < 3
        return DataFrame(result, index=self._orig.index)


# Traceback (ValueError)
s = pd.Series(['name', 'email|Name|address', 'address|email'])
s.str.get_dummies(sep='|')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-1a39a6dcd56b> in <module>()
----> 1 s.str.get_dummies(sep='|')

/Users/dgrady/anaconda/envs/python3/lib/python3.5/site-packages/pandas/core/strings.py in get_dummies(self, sep)
1377         data = self._orig.astype(str) if self._is_categorical else self._data
1378         result = str_get_dummies(data, sep)
-> 1379         return self._wrap_result(result, use_codes=(not self._is_categorical))
1380
1381     @copy(str_translate)

/Users/dgrady/anaconda/envs/python3/lib/python3.5/site-packages/pandas/core/strings.py in _wrap_result(self, result, use_codes, name)
1100         if not hasattr(result, 'ndim'):
1101             return result
-> 1102         name = name or getattr(result, 'name', None) or self._orig.name
1103
1104         if result.ndim == 1:

/Users/dgrady/anaconda/envs/python3/lib/python3.5/site-packages/pandas/core/generic.py in __nonzero__(self)
729         raise ValueError("The truth value of a {0} is ambiguous. "
730                          "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
--> 731                          .format(self.__class__.__name__))
732
733     __bool__ = __nonzero__

ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

# Fixed code
def _wrap_result(self, result, use_codes=True, name=None):
    # for category, we do the stuff on the categories, so blow it up
    # to the full series again
    # But for some operations, we have to do the stuff on the full values,
    # so make it possible to skip this step as the method already did this
    # before the transformation...
    if use_codes and self._is_categorical:
        result = take_1d(result, self._orig.cat.codes)

    # leave as it is to keep extract and get_dummies results
    # can be merged to _wrap_result_expand in v0.17
    from pandas.core.series import Series
    from pandas.core.frame import DataFrame
    from pandas.core.index import Index

    if not hasattr(result, "ndim"):
        return result

    if result.ndim == 1:
        # Wait until we are sure result is a Series or Index before
        # checking attributes (GH 12180)
        name = name or getattr(result, "name", None) or self._orig.name
        if isinstance(self._orig, Index):
            # if result is a boolean np.array, return the np.array
            # instead of wrapping it into a boolean Index (GH 8875)
            if is_bool_dtype(result):
                return result
            return Index(result, name=name)
        return Series(result, index=self._orig.index, name=name)
    else:
        assert result.ndim < 3
        return DataFrame(result, index=self._orig.index)