Skip to content

[FEATURE-REQUEST] How to apply same MinMaxScaling to a set of columns? #1548

Answered by JovanVeljanoski
yohplala asked this question in Q&A
Discussion options

You must be logged in to vote

What you describe is not how the MinMaxScaler is expected to work, but nothing stops you from doing this yourself.

Find the min and the max of the features you are interested in, and you can just use the formula for MinMax scaling (you can look this up online). You could write your own function for this, something like

def custom_minmax(df, features, fmin, fmax, a=0, b=1):
  for feat in features:
    df["scaled_"+feat] = (b-a)*(df[feat] - fmin)/(fmax - fmin) + a
  return df

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by yohplala
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1547 on August 28, 2021 14:41.