0

I want add the row values of different three columns in pandas. like

dctr  mctr  tctr
100    20    10
20     90    70``
30     10    80 
40     05    120
50     20    60 

I want add these three columns by rows values to total_ctr. Here what type of comment want to be used in pandas.??

Like this I have seven total values and I want to add these seven different values into a new dataframe. Is that possible. Likewise "total_ctr", "total_cpc", "total_avg", "total_cost" and so on. I want to make this as a new dataframe from these total values

I know there's a similar question on sum of rows, but I've not managed to get that one to work for this problem.

1 Answers1

0

This will work, assuming above is dataframe named df

df['total_ctr'] = df.sum(axis=1)
Rahul Agarwal
  • 4,034
  • 7
  • 27
  • 51
  • Like this I have seven total values and I want to add these seven different values into a new dataframe. Is that possible. Likewise "total_ctr", "total_cpc", "total_avg", "total_cost" and so on. I want to make this as a new dataframe from these total values – Kumar Prasanna Nov 13 '18 at 12:47
  • Yes you can, make a new df with these new 7 columns or drop the old columns. Check out this link https://stackoverflow.com/questions/28538536/deleting-multiple-columns-based-on-column-names-in-pandas – Rahul Agarwal Nov 13 '18 at 13:02