更新时间:2023-01-31 12:08:55
I think you are looking for the sklearn.preprocessing.MinMaxScaler
. That will allow you to scale to a given range.
因此,您的情况应该是:
So in your case it would be:
scaler = preprocessing.MinMaxScaler(feature_range=(0,1))
df['scaled_event_counts'] = scaler.fit_transform(df['Event_Counts'])
要缩放整个df:
scaled_df = scaler.fit_transform(df)
print(scaled_df)
[[ 0. 0.99722347 0. 1. ]
[ 1. 1. 1. 0. ]
[ 1. 0. 0. 1. ]]