简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM