user3447653
user3447653

Reputation: 4158

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.

Upvotes: 1

Views: 6610

Answers (1)

user2285236
user2285236

Reputation:

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.

Upvotes: 4

Related Questions