I am trying to append my data frame to new data frame but I am getting a 'Argument must be a string or number ' error.
# The encoders
le = LabelEncoder()
ohc = OneHotEncoder()
for col in num_ohc_cols.index:
# Integer encode the string categories
dat = le.fit_transform(df_ohc[col]).astype(np.int)
# Remove the original column from the dataframe
df_ohc = df_ohc.drop(col,axis=1)
# One hot encode the data--this returns a sparse array
new_dat = ohc.fit_transform(dat.reshape(-1,1))
# Create unique column names
n_cols = new_dat.shape[1]
col_names = ['_'.join([col,str(x)]) for x in range(n_cols)]
print(col_names)
# Create the new dataframe
I'm getting the error here, in creating new dataframe:
new_df=pd.DataFrame(
new_dat.toarray(),index=df_ohc.index,columns=col_names)