Search code examples
pythonpandasnormalization

Normalize data in pandas dataframe


I would like to normalise this value in the range of 0 to 100. I have these values in a pandas dataframe.

    Latitude    Longitude
    25.436596   -100.887300
    25.436596   -100.887700
    25.436493   -100.887421
    25.436570   -100.887344
    25.436596   -100.887321

I am able to normalize the data between -1 to 1 using

    df_norm1 = (df - df.mean()) / (df.max() - df.min())

Can I normalise the same data in the range of 0 to 100. Any help would be greatly appreciated.


Solution

  • Change it to:

    100 * (df - df.min()) / (df.max() - df.min())
    

    The (df - df.min()) / (df.max() - df.min()) part is min-max normalization where the new scale is [0, 1]. If you multiply that with 100, you get your desired range.