(df, col, n_features)
return unique.set_index(col)
Hash the unique values in the specified column in the given dataframe, creating n_features
Hash the unique values in the specified column in the given dataframe, creating n_features
Hash the unique values in the specified column in the given dataframe creating n_features
def hasher(df, col, n_features):
        """
        Hash the unique values in the specified column in the given dataframe, creating n_features
        """
        
        unique = pd.DataFrame(df[col].unique(), columns=[col])
        fh = FeatureHasher(n_features=n_features, input_type="string")
        hashed = fh.fit_transform(unique.loc[:, col])
        unique = unique.join(pd.DataFrame(hashed.toarray()).add_prefix(col))
        return unique.set_index(col)
def hasher ( df , col , n_features ) : unique = pd . DataFrame ( df [ col ] . unique ( ) , columns = [ col ] ) fh = FeatureHasher ( n_features = n_features , input_type = "string" ) hashed = fh . fit_transform ( unique . loc [ : , col ] ) unique = unique . join ( pd . DataFrame ( hashed . toarray ( ) ) . add_prefix ( col ) ) return unique . set_index ( col )