def str_get_dummies(arr, sep='<STR_LIT:|>'):
arr = arr.fillna('<STR_LIT>')<EOL>try:<EOL><INDENT>arr = sep + arr + sep<EOL><DEDENT>except TypeError:<EOL><INDENT>arr = sep + arr.astype(str) + sep<EOL><DEDENT>tags = set()<EOL>for ts in arr.str.split(sep):<EOL><INDENT>tags.update(ts)<EOL><DEDENT>tags = sorted(tags - {"<STR_LIT>"})<EOL>dummies = np.empty((len(arr), len(tags)), dtype=np.int64)<EOL>for i, t in enumerate(tags):<EOL><INDENT>pat = sep + t + sep<EOL>dummies[:, i] = lib.map_infer(arr.values, lambda x: pat in x)<EOL><DEDENT>return dummies, tags<EOL>
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