Split each string in the Series by sep and return a DataFrame
    of dummy/indicator variables.

    Parameters
    ----------
    sep : str, default "|"
        String to split on.

    Returns
    -------
    DataFrame
        Dummy variables corresponding to values of the Series.

    See Also
    --------
    get_dummies : Convert categorical variable into dummy/indicator
        variables.

    Examples
    --------
    >>> pd.Series(['a|b', 'a', 'a|c']).str.get_dummies()
       a  b  c
    0  1  1  0
    1  1  0  0
    2  1  0  1

    >>> pd.Series(['a|b', np.nan, 'a|c']).str.get_dummies()
       a  b  c
    0  1  1  0
    1  0  0  0
    2  1  0  1

def str_get_dummies(arr, sep='|'):
    """
    Split each string in the Series by sep and return a DataFrame
    of dummy/indicator variables.

    Parameters
    ----------
    sep : str, default "|"
        String to split on.

    Returns
    -------
    DataFrame
        Dummy variables corresponding to values of the Series.

    See Also
    --------
    get_dummies : Convert categorical variable into dummy/indicator
        variables.

    Examples
    --------
    >>> pd.Series(['a|b', 'a', 'a|c']).str.get_dummies()
       a  b  c
    0  1  1  0
    1  1  0  0
    2  1  0  1

    >>> pd.Series(['a|b', np.nan, 'a|c']).str.get_dummies()
       a  b  c
    0  1  1  0
    1  0  0  0
    2  1  0  1
    """
    arr = arr.fillna('')
    try:
        arr = sep + arr + sep
    except TypeError:
        arr = sep + arr.astype(str) + sep

    tags = set()
    for ts in arr.str.split(sep):
        tags.update(ts)
    tags = sorted(tags - {""})

    dummies = np.empty((len(arr), len(tags)), dtype=np.int64)

    for i, t in enumerate(tags):
        pat = sep + t + sep
        dummies[:, i] = lib.map_infer(arr.values, lambda x: pat in x)
    return dummies, tags