I am new to python. I am trying to learn pandas with below example. I have two data frames below.
First one is,
CCP_DETAILS_SID BASE_LINE
1 1235.89
2 369.32
3 9863.1
And Second one is,
CCP_DETAILS_SID PERIOD_SID GROWTH
1 601 0.1
1 602 0.2
1 603 0.3
2 601 0.1
2 602 0.2
2 603 0.3
3 601 0.1
3 602 0.2
3 603 0.3
by merging above two, I am trying to calculate a field called 'PROJECTION_SALES'. Formula and examples for the field i have listed below.
Projection_Sales=(Base_Line)*(1+Growth) and the merge or join condition between two data frames is CCP_DETAILS_SID.
Examples
Projection_Sales(ccp_details_sid=1 and period_sid=601)=1235.89*(1+0.1)
Projection_Sales(ccp_details_sid=1 and period_sid=602)=1235.89*(1+0.1)*(1+0.2)
Projection_Sales(ccp_details_sid=1 and period_sid=603)=1235.89*(1+0.1)*(1+0.2)*(1+0.3)
Projection_Sales(ccp_details_sid=2 and period_sid=601)=369.32*(1+0.1).
Same way of calculation applies to other rows in the data frames. And sample output i listed below.
CCP_DETAILS_SID PERIOD_SID PROJECTION_SALES
1 601 1359.479
1 602 1631.3748
1 603 2120.78724
2 601 406.252
2 602 487.5024
2 603 633.75312
3 601 10849.41
3 602 13019.292
3 603 16925.0796
I have tried some thing like below
pd.merge(first,second,how='inner',on='CCP_DETAILS_SID')
After this step i need to extend code with the use of cumprod. Because you can observe above examples are having cumulative product logic etc.
Can you people please suggest me a way to complete this calculation?.