I have a dataframe (df) with columns like this:
Column 1 | Column 2 | Column 3 |
---|---|---|
-0.01784 | 90.12232 | 0.12323 |
36.50000 | 1.32003 | 30.10937 |
-187.03982 | -1.09322 | -3.20091 |
And a formula like this:
y = ((maximum – minimum)**2) + ((x – 10)**2), where
maximum = the maximum value in the column
minimum = the minimum value in the column
x = input value from the column (each cell one by one)
y = output value (the result for each cell)
The question is:
How can I put every new value from column into X, receive Y and make it for each column?
The result should be like:
Column 1 | Column 2 | Column 3 |
---|---|---|
50070.40824 | 14739.86089 | 1207.12533 |
50672.30112 | 8395.61661 | 1513.96151 |
88794.74179 | 8443.33426 | 1283.83877 |
Thanks for the help!!!
>Solution :
You can use:
df.sub(10).pow(2).add(df.max().sub(df.min()).pow(2))
Or:
(df-10)**2 + (df.max()-df.min())**2
Output:
Column 1 Column 2 Column 3
0 50070.408244 14739.860900 1207.125339
1 50672.301126 8395.616617 1513.961515
2 88794.741791 8443.334267 1283.838779