pandas.core.strings.StringMethods.get_dummies

StringMethods.get_dummies(sep='|')

Split each string by sep and return a frame of dummy/indicator variables.

Examples

>>> 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

See also pd.get_dummies.