Before applying onehotencoder do we need to first factorize or apply label encoder as on using below code where i am trying to apply onehot encoder on multiple columns at once getting below error
Error “int() argument must be a string, a bytes-like object or a number, not ‘Timestamp’”
Categorical boolean mask
categorical_feature_mask = demand_sales_data.dtypes==object
import OneHotEncoder
from sklearn.preprocessing import OneHotEncoder
instantiate OneHotEncoder
ohe = OneHotEncoder(categorical_features = categorical_feature_mask, sparse=False )
categorical_features = boolean mask for categorical columns
sparse = False output an array not sparse matrix
apply OneHotEncoder on categorical feature columns
X_ohe = ohe.fit_transform(demand_sales_data) # It returns an numpy array