# define a method to scale data, looping thru the columns, and passing a scaler def scale_data(data, columns, scaler): for col in columns: data[col] = scaler.fit_transform(data[col].values.reshape(-1, 1)) return data code example
Example: standardscaler into df data frame pandas
scaled_features = StandardScaler().fit_transform(df.values)
scaled_features_df = pd.DataFrame(scaled_features, index=df.index, columns=df.columns)