title: Pandas groupby.sum for all columns
body: <p>I have a dataset with a set of columns I want to sum for each row. The columns in question all follow a specific naming pattern that I have been able to group in the past via the .sum() function:</p>
  <pre><code>pd.DataFrame.sum(data.filter(regex=r'_name$'),axis=1)
  </code></pre>
  <p>Now, I need to complete this same function, but, when grouped by a value of a column:</p>
  <pre><code>data.groupby('group').sum(data.filter(regex=r'_name$'),axis=1)
  </code></pre>
  <p>However, this does not appear to work as the .sum() function now does not expect any filtered columns. Is there another way to approach this keeping my data.filter() code?</p>
  <p>Example toy dataset. Real dataset contains over 500 columns where all columns are not cleanly ordered:</p>
  <pre><code>toy_data = ({'id':[1,2,3,4,5,6],
           'group': [&quot;a&quot;,&quot;a&quot;,&quot;b&quot;,&quot;b&quot;,&quot;c&quot;,&quot;c&quot;],
           'a_name': [1,6,7,3,7,3],
           'b_name': [4,9,2,4,0,2],
           'c_not': [5,7,8,4,2,5],
           'q_name': [4,6,8,2,1,4]
      })
  df = pd.DataFrame(toy_data, columns=['id','group','a_name','b_name','c_not','q_name'])
  </code></pre>
  <p>Edit: Missed this in original post. My objective is to get a variable ;sum&quot; of the summation of all the selected columns as shown below:</p>
  <p><a href="https://i.stack.imgur.com/HU1LJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HU1LJ.png" alt="enter image description here" /></a></p>