I have a pandas data-frame:
         df
                  Case  Type  Incr_1_3  Incr_2_3 Incr_3_3  Saving_1_3 Saving_2_3 Saving_3_3
              0    HI    PC1   0.046      2.388   0.388       0.254     2.539      2.539                   
              1    HI    PC2   0.000      0.024   0.024       0.026     0.054      0.054                
              2    LO    PC1   0.000      0.024   0.024       0.026     0.054      0.054
              3    LO    PC2   0.030      0.054   0.074       0.126     0.754      0.036
              4    RF    PC1   0.030      0.054   0.074       0.126     0.754      0.036
              4    RF    PC2   0.030      0.054   0.074       0.126     0.754      0.036
I want to calculate the difference between "Saving" and "Incr" columns. The code for each new column looks like this:
                df['D_1_3']=df['Saving_1_3']-df['Incr_1_3']
                df['D_2_3']=df['Saving_2_3']-df['Incr_2_3']
                df['D_2_3']=df['Saving_3_3']-df['Incr_3_3']
I can do it manually, however, I can't figure out a more efficient way to perform the calculation since my actually dataframe has more columns.
I tried following method:
          saving_list=['Saving_1_3','Saving_2_3','Saving_3_3']
          cost_list=['Incr_1_3','Incr_2_3','Incr_3_3']
          df[['A','B','C']]=df[saving_list]-df[cost_list]
It gives me the following error message:
          "ValueError: Columns must be same length as key"
Thank you for your help!
 
     
    