When I use Pandas, I have a problem. My task is this:
df=pd.DataFrame([(1,2,3,4,5,6),(1,2,3,4,5,6),(1,2,3,4,5,6)],columns=['a','b','c','d','e','f'])
Out:
a b c d e f
0 1 2 3 4 5 6
1 1 2 3 4 5 6
2 1 2 3 4 5 6
what I want to do is that the output frame looks like this:
Out:
s1 s2 s3
0 3 7 11
1 3 7 11
2 3 7 11
In other words, sum the columns (a, b), (c, d), (e, f) separately and rename the column names of the results as (s1, s2, s3). Can anyone help solve this problem in Pandas? Thank you very much.