[Solved] Forecasting basis the historical figures


You need to join those two dataframes to perform multiplication of two columns.

merged_df = segmentallocation.merge(second,on=['year','month'],how='left',suffixes=['','_second'])

for c in interested_columns:
        merged_df['allocation'+str(c)] = merged_df['%of allocation'+str(c)] * merged_df[c] 

merged_df


    year    month   segment x   y   z   k   %of allocationx %of allocationy %of allocationz %of allocationk x_second    y_second    z_second    k_second    allocationx allocationy allocationz allocationk
0   2018    FEB A   2094663 2094663 2094663 2094663 1.000000    1.000000    1.000000    1.000000    7,771,691   738,041 217,027 17,363  2.094663e+06    2.094663e+06    2.094663e+06    2.094663e+06
1   2018    JAN A   1600    1600    1600    1600    0.631662    0.631662    0.631662    0.631662    9,267,581   627,129 254,110 14,980  1.010659e+03    1.010659e+03    1.010659e+03    1.010659e+03
2   2018    JAN B   700 700 700 700 0.276352    0.276352    0.276352    0.276352    9,267,581   627,129 254,110 14,980  1.934465e+02    1.934465e+02    1.934465e+02    1.934465e+02
3   2018    JAN C   233 233 233 233 0.091986    0.091986    0.091986    0.091986    9,267,581   627,129 254,110 14,980  2.143269e+01    2.143269e+01    2.143269e+01    2.143269e+01

3

solved Forecasting basis the historical figures