python : Compute columns of data frames and add them to new columns
To create a new df column based on the calculations of two or more other columns, you would have to define a new column and set it equal to your equation. For example:
df['new_col'] = df['col_1'] * df['col_2']
I want to make a new column by calculating existing columns.
For example df
df
no    data1    data2
1      10        15
2      51        46
3      36        20
......
i want to make this
new_df
no    data1    data2    data1/-2    data1/2    data2/-2    data2/2
1      10       15         -5          5         -7.5        7.5
2      51       46        -25.5      25.5        -23         23
3      36       20         -18        18          -9         9
but i don't know how to make this as efficient as possible