I'm trying to change Categorical Data from my data frame using the code
CATEGORICAL_COLUMNS = ['sex','n_siblings_spouses', 'parch', 'class',
'embark_town', 'alone']
for i in CATEGORICAL_COLUMNS:
dfTrain[i] = pd.factorize(dfTrain.i)[0]
dfTrain.head()
But I get the error:
'DataFrame' object has no attribute 'i'
How would I fix this?