First code snippet:
imp.fit_transform(dataset['Age'].values.reshape(-1,1))
dataset['Age'] = dataset['Age'].values.reshape(-1,1)
Second code snippet:
imp.fit(dataset['Age'].values.reshape(-1, 1))
dataset['Age'] = imp.transform(dataset['Age'].values.reshape(-1, 1))
The first code snippet does not make any change to the age column of my dataset.
The first code does not change the Age
column because you are not asking it to do it ;) you apply the fit_transform
function but you do not use it to change the dataset.
I don't know what is imp
, but a more correct implementation of the first piece of code would certainly be something like :
dataset['Age'] = imp.fit_transform(dataset['Age'].values.reshape(-1,1))