Demo entry 6357528

dd

   

Submitted by anonymous on Apr 23, 2017 at 07:34
Language: Python 3. Code size: 384 Bytes.

from sklearn.preprocessing import OneHotEncoder, LabelEncoder
import numpy as np
import pandas as pd

le = LabelEncoder()
data_df['street_address'] = le.fit_transform(data_df['street_address'])

ohe = OneHotEncoder(n_values='auto', categorical_features='all', dtype=np.float64, sparse=True, handle_unknown='error')
one_hot_matrix = ohe.fit_transform(data_df['street_address'])

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).