scikit-learn scalers in DataFrames

import pandas as pd
from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()

df = pd.DataFrame({'alpha': [0.11, 0.18, 0.05, -0.01, -0.42],
                   'beta':  [16.8, 27.6, -23.4, 4.0, 15.1],
                   'cls':   ['a', 'b', 'b', 'a', 'b']})

df[['alpha', 'beta']] = scaler.fit_transform(df[['alpha', 'beta']])

df
alpha beta cls
0 0.607625 0.504570 a
1 0.939920 1.125225 b
2 0.322801 -1.805647 b
3 0.037977 -0.231022 a
4 -1.908323 0.406874 b

If you spot any errors please let me know on twitter.