def str_get_dummies(arr, sep='|'):
 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 - set([''])))
 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)

def str_get_dummies ( arr , sep = '|' ) : 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 - set ( [ '' ] ) ) ) 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 )
split each string in the series by sep and return a frame of dummy/indicator variables .