Create dummies for the elements of a set-valued column. Operates in place.
    Args:
        df: data frame
        columns: either a dictionary of column: values pairs or a collection of columns.
        cast: whether or not to cast values to set
        drop: whether or not to drop the binarized columns
    TODO: make interface same as binarize(). merge the two?

def binarize_sets(df, columns, cast=False, drop=True, min_freq=None):
    """
    Create dummies for the elements of a set-valued column. Operates in place.
    Args:
        df: data frame
        columns: either a dictionary of column: values pairs or a collection of columns.
        cast: whether or not to cast values to set
        drop: whether or not to drop the binarized columns
    TODO: make interface same as binarize(). merge the two?
    """
    for column in columns:
        d = df[column].dropna()  # avoid nulls
        if cast:
            d = d.apply(set)

        values = columns[column] if isinstance(columns, dict) else util.union(d)
        for value in values:
            name = values[value] if type(values) is dict else str(value)
            column_name = column + '_' + name.replace(' ', '_')
            series = d.apply(lambda c: value in c)
            series.fillna(0, inplace=True)
            if not min_freq or series.sum() >= min_freq:
                df[column_name] = series

    if drop:
        # list(columns) will return keys if columns was dict
        df.drop(list(columns), axis=1, inplace=True)

    return df