title: How to iterate through column headers in pandas
body: <p>I'm trying to iterate through column headers and populate a list containing the mean revenue for each category.
  I'm getting this error and I tried a bunch of different things trying to fix it.
  So my dataframe looks like this (looks like I dont have enough points to paste an image, but here is a link to it):
  <a href="https://i.stack.imgur.com/j1c0b.jpg" rel="noreferrer">each row in the dataframe represent an idividual movie. column revenue_adj populated with revenue values, one column for each genre populated with TRUE/FALSE indicating that the movie falls under that specific genre.</a></p>
  
  <p>this code works fine, but I would like to do it in a for loop insteadgenrev1 </p>
  
  <pre><code>genrev1= df.query('action == True')['revenue_adj'].mean()
  genrev2 = df.query('adventure == True')['revenue_adj'].mean()
  genrev3 = df.query('animation == True')['revenue_adj'].mean()
  genrev4 = df.query('comedy == True')['revenue_adj'].mean()
  genrev5 = df.query('crime == True')['revenue_adj'].mean()
  genrev6 = df.query('documentary == True')['revenue_adj'].mean()
  genrev7 = df.query('drama == True')['revenue_adj'].mean()
  genrev8 = df.query('family == True')['revenue_adj'].mean()
  </code></pre>
  
  <p>I tried the following loop without success:</p>
  
  <pre><code>genheads = ['action', 'adventure', 'animation', 'comedy', 'crime', 'documentary', 'drama', 'family']
  
  genres2 = genheads
  genrev = []
  for gen in genres2:
      genrev.append(df.query('gen == True')['revenue_adj'].mean())
  </code></pre>
  
  <p>I get an error saying "gen is not defined"
  Instead of gen, I have tried:</p>
  
  <pre><code>df[gen] == True
  '@df[gen] == True'
  '@gen == True'
  </code></pre>
  
  <p>I been stuck on this for several weeks and any help on this would be soooo appreciated!!</p>