from sklearn.preprocessing import StandardScaler
import pandas as pd
data = {'Age': [20, 25, 30, 35, 40],
'Salary': [20000, 25000, 30000, 35000, 40000]}
df = pd.DataFrame(data)
scaler = StandardScaler()
df[['Age_scaled', 'Salary_scaled']] = scaler.fit_transform(df[['Age', 'Salary']])
print(df)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter