title: Create a list of columns and sum them in a new column with Pandas (Python)
body: <p>I do know some posts are quite similar to my question but none of them succeded in giving me the correct answer. I want, for each row of a pandas dataframe, to perform the sum of values taken from several columns. As the number of columns tends to vary, I want this sum to be performed from a list of columns.</p>
  
  <p>At the moment my code looks like this:</p>
  
  <pre><code>df['Sum'] = df['Col A'] + df['Col E'] + df['Col Z']
  </code></pre>
  
  <p>I want it to be something like :</p>
  
  <pre><code>df['Sum'] = sum(list_of_my_columns)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>df[list_of_my_columns].sum(axis=1)
  </code></pre>
  
  <p>But both of them return an error. Might be because my list isn't properly created? This is how I did it:</p>
  
  <pre><code>list_of_my_columns = [df['Col A'], df['Col E'], df['Col Z']]
  </code></pre>
  
  <p>But this doesn't seem to work... Any ideas ? Thank you !</p>