python standardize dataframe code example
Example 1: normalize data python pandas
import pandas as pd
from sklearn import preprocessing
x = df.values #returns a numpy array
min_max_scaler = preprocessing.MinMaxScaler()
x_scaled = min_max_scaler.fit_transform(x)
df = pd.DataFrame(x_scaled)
Example 2: standardise columns python
from sklearn.preprocessing import StandardScaler
df[['col1', 'col2']] = StandardScaler().fit_transform(df[['col1', 'col2']])