I currently have the following dataframe and would like to fill in the empty "weight" cells with a drifted value (explained below).
For values above 234 in the 'weight' column I would like to have the following values:
And, for values below 234, I would like to have the following values:
What is the best and most Pythonic way to achieve my objective in Python 3 and Pandas? (I'm open to using libraries that have this transformation built in; however, I'm yet to find one myself.)
EDIT 1: The textual version of the above:
The following is a simple version of the above dataframe.
A B
0 1 NaN
1 1 3
2 4 NaN
I would like all values above the value "3" in column B to take on the following formula. Note values within apostrophes are coordinates representing the x and y labels of the above dataframe.
"1B"/(1 + "0B")
I would like all values below the value "3" in column B to take on the following formula.
"1B" * (1 + "2A")
Note that the coordinates' relative distance to the current cell does not change. In Excel terminology, the references are "relative" and not "absolute". Read more about terminology here.