Say I have the following frame:
a=pd.DataFrame(np.random.randn(5, 5),columns=["Col_1","X_1","X_2","X_3","Col_3"])
a
I want to sum up coumns X_1 ,X_2 ,X_3 in an new column Col_2 within the frame. I konw that I can do:
b=a.filter(like="X")
pd.concat([a.drop(b.columns,axis=1),b.sum(axis=1).rename("Col_2")],axis=1)
However, I am looking for a more clean and lean one line version of doing this. Is there possibly something that can be done with .groupby?
