(df, col)
return unique.set_index(col)
Convert strings to their unicode representation and then apply one hot encoding, creating one feature for each unique character in the column. 
        This can be useful when similarity between strings is significant.
Convert strings to their unicode representation and then apply one hot encoding, creating one feature for each unique character in the column. 
        This can be useful when similarity between strings is significant.
Convert strings to their unicode representation and then apply one hot encoding creating one feature for each unique character in the column . This can be useful when similarity between strings is significant .
def text_similarity(df, col):
        """
        Convert strings to their unicode representation and then apply one hot encoding, creating one feature for each unique character in the column. 
        This can be useful when similarity between strings is significant.
        """
        
        unique = pd.DataFrame(df[col].unique(), columns=[col])
        
        encoded = pd.DataFrame(unique.loc[:,col].apply(lambda s: [ord(a) for a in s]), index=unique.index)
        
        mlb = preprocessing.MultiLabelBinarizer()
        encoded = pd.DataFrame(mlb.fit_transform(encoded[col]),columns=mlb.classes_, index=encoded.index).add_prefix(col+"_")
        
        unique = unique.join(encoded)
        
        return unique.set_index(col)
def text_similarity ( df , col ) : unique = pd . DataFrame ( df [ col ] . unique ( ) , columns = [ col ] ) encoded = pd . DataFrame ( unique . loc [ : , col ] . apply ( lambda s : [ ord ( a ) for a in s ] ) , index = unique . index ) mlb = preprocessing . MultiLabelBinarizer ( ) encoded = pd . DataFrame ( mlb . fit_transform ( encoded [ col ] ) , columns = mlb . classes_ , index = encoded . index ) . add_prefix ( col + "_" ) unique = unique . join ( encoded ) return unique . set_index ( col )