I have been using pandas library for data manipulation. And I am stuck somewhere while doing the below calculation.
I have below table in my excel file which contains two columns and I need to create third column (cap). I need to do this excel calculation of third column in my program using python pandas.
First I will create the below dataframe DF which contains two columns and I need to create third column in df using Excel formulas in python.
Data frame (DF):-
Period rates
01-01-2021 0.0028
01-02-2021 0.0082
01-03-2021 0.0020
01-04-2021 0.0043
01-05-2021 0.0066
Excel Table:-
A B C
1 Period rates cap
2 01-01-2021 0.0028 =if(month(A2)=04,1,(1+$B3)*C3)
3 01-02-2021 0.0082 =if(month(A3)=04,1,(1+$B4)*C4)
4 01-03-2021 0.0020 =if(month(A4)=04,1,(1+$B5)*C5)
5 01-04-2021 0.0043 =if(month(A5)=04,1,(1+$B6)*C6)
6 01-05-2021 0.0066 =if(month(A6)=04,1,(1+$B7)*C7)
I have just created the third column (cap) to understand the formula. And I need to do this in my python program.