Use sklearn StandardScaler() only on certain feature columns

PHOTO EMBED

Thu Mar 25 2021 17:15:12 GMT+0000 (Coordinated Universal Time)

Saved by @chenyangsu #python

scaled_features = data.copy()

col_names = ['Age', 'Weight']
features = scaled_features[col_names]
scaler = StandardScaler().fit(features.values)
features = scaler.transform(features.values)

scaled_features[col_names] = features
print(scaled_features)
content_copyCOPY

https://stackoverflow.com/a/38420977