📜  python 函数来缩放数据框 pandas 中的选定特征 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:07.650000             🧑  作者: Mango

代码示例1
# make a copy of dataframe
scaled_features = df.copy()

col_names = ['co_1', 'col_2', 'col_3', 'col_4']
features = scaled_features[col_names]

# Use scaler of choice; here Standard scaler is used
scaler = StandardScaler().fit(features.values)
features = scaler.transform(features.values)

scaled_features[col_names] = features