Created
September 16, 2021 17:14
-
-
Save sengstacken/582dea2ba873af644f2fdca4e996719b to your computer and use it in GitHub Desktop.
scale data with pandas without warnings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scale_cols = ['Time','Amount'] | |
scaler = StandardScaler() | |
# fit scaler | |
scaler.fit(train_df[scale_cols].to_numpy()) | |
# make copies of dataframes | |
train_df_ = train_df.copy() | |
val_df_ = val_df.copy() | |
test_df_ = test_df.copy() | |
# apply scaler | |
train_df_.loc[:,scale_cols] = scaler.transform(train_df[scale_cols].values) | |
val_df_.loc[:,scale_cols] = scaler.transform(val_df[scale_cols].values) | |
test_df_.loc[:,scale_cols] = scaler.transform(test_df[scale_cols].values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment