Standard Scaler
Mon Nov 18 2024 15:59:00 GMT+0000 (Coordinated Universal Time)
Saved by
@login123
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)
content_copyCOPY
Comments