I have been using pandas for a little while. In Excel, we frequently use drag functionality as in the picture.
The equivalent of that which I am using in pandas is something like:
def apply_drag(row, initial_value, initial_index, rate):
count = (row.name - initial_index).days
return initial_value * math.pow(1 + rate, count)
custom_nav_df["nav"] = custom_nav_df.apply(apply_drag, args=(initial_value, initial_index, risk_free_rate), axis=1)
While this serves my purpose, I presume there should be a simpler way to do such a trivial task. Also, for this case, if the date is not continuous, it will give wrong results.
What should be the simplest way to achieve this where data for the current row is achieved from previous row (let's say arithmetic or geometric progression).