I friends. I would like to ask how to orgnize subtruction of columns. so the dataframe is as below:
when I subtruct columns from each other I use the following code:
but I need to subtract b from a, c from b and so on and combine(plus) the results in one column
thanks in advance
when I subtruct columns from each other I use the following code:
1 |
df[ 'new' ] = df.column_1 - df.column_2 |
1 |
df = pd.DataFrame(np.random.randint(low = 0 , high = 10 , size = ( 5 , 5 )),columns = [ 'a' , 'b' , 'c' , 'd' , 'e' ]) |
1 2 3 4 5 6 |
a b c d e 6 5 6 8 3 4 9 2 4 2 1 7 9 4 3 3 1 5 2 3 2 8 3 5 7 |