Skip to content

Instantly share code, notes, and snippets.

@FelixChop
Created March 26, 2020 10:44
Show Gist options
  • Save FelixChop/e7ca8f3253a03d0e4bfe7170af92ffd4 to your computer and use it in GitHub Desktop.
Save FelixChop/e7ca8f3253a03d0e4bfe7170af92ffd4 to your computer and use it in GitHub Desktop.
transformed_age = \
pd.DataFrame(imputer_age.transform(train[['Age']]),
columns=['Age', 'Age_missing'],
index=train.index) # the most important line: do not forget the index
train = train.drop(columns=['Age']).join(transformed_age)
transformed_age = \
pd.DataFrame(imputer_age.transform(validation[['Age']]),
columns=['Age', 'Age_missing'],
index=validation.index) # the most important line: do not forget the index
validation = validation.drop(columns=['Age']).join(transformed_age)
transformed_age = \
pd.DataFrame(imputer_age.transform(holdout[['Age']]),
columns=['Age', 'Age_missing'],
index=holdout.index) # the most important line: do not forget the index
holdout = holdout.drop(columns=['Age']).join(transformed_age)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment