Skip to content

Instantly share code, notes, and snippets.

@amandaiglesiasmoreno
Created November 22, 2021 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amandaiglesiasmoreno/13502116e5684b853f27296413e0bd68 to your computer and use it in GitHub Desktop.
Save amandaiglesiasmoreno/13502116e5684b853f27296413e0bd68 to your computer and use it in GitHub Desktop.
# min-max normalization (numeric variables)
min_max_columns = ['tenure', 'MonthlyCharges', 'TotalCharges']
# scale numerical variables using min max scaler
for column in min_max_columns:
# minimum value of the column
min_column = df_telco_transformed[column].min()
# maximum value of the column
max_column = df_telco_transformed[column].max()
# min max scaler
df_telco_transformed[column] = (df_telco_transformed[column] - min_column) / (max_column - min_column)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment