'Applying math formule to Pandas Series elements

Variables data, maxs and mins are Pandas Series with the same indexes.

I want to match the elements of the three variables by indexes.

How can I apply this function properly ?

def denormalize(data, maxs, mins):
    return (maxs - data) / (maxs - mins)


Solution 1:[1]

IIUC:

The results of the formula are wrong.

def denormalize(data, maxs, mins):
    return (mins - maxs) * data + maxs

This is the reverse formula of normalize: (maxs - data) / (maxs - mins)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Corralien