title: Pandas Query with Variable as Column Name
body: <p>Passing on new application of information I learned that was part of another question:  <a href="https://stackoverflow.com/questions/23974664/unable-to-query-a-local-variable-in-pandas-0-14-0">Unable to query a local variable in pandas 0.14.0</a></p>
  
  <p>Credit and thanks to user @choldgraf.  I'm applying his answer from the above link differently.</p>
  
  <p>Objective: To use a variable as the column name in a query</p>
  
  <p>Failed examples:</p>
  
  <pre><code>import pandas as pd
  fooframe = pd.DataFrame({'Size':['Large', 'Medium', 'Small', 'Tiny'], 'Color':[1, 2, 3, 4]})
  myvar = 'Size'
  subframe = fooframe.query("myvar == 'Large'")
  </code></pre>
  
  <p>The code above returns a key error for 'myvar'.</p>
  
  <pre><code>import pandas as pd
  fooframe = pd.DataFrame({'Size':['Large', 'Medium', 'Small', 'Tiny'], 'Color':[1, 2, 3, 4]})
  myvar = 'Size'
  subframe = fooframe.query("@myvar == 'Large'")
  </code></pre>
  
  <p>The code above adds "@" before myvar in the query to reference myvar as a local variable. However, the code still returns an error.</p>