Given a dataframe as follows:
x1 x2 x3 x4 x5 x6
1 2 3 4 5 6
3 4 5 6 3 3
1 2 3 6 1 2
How could i create a new columns of 'sum' that just adds x1 + x3 + x4
x1 x2 x3 x4 x5 x6
1 2 3 4 5 6
3 4 5 6 3 3
1 2 3 6 1 2
In my actual dataframe i have about 100 columns, so is there a way to do this without having to manually write x1 + x3 + ... + xn
e.g. given a list [x1, x3, x4.. xn] df['sum'] = sum(df[list]) ? Any help appreciated, thanks.