title: get column number from label in DataFrame
body: <p>how to get the column number from label in DataFrame, for instance.</p>
  
  <pre><code>import pandas as pd
  from pandas import DataFrame
  
  df = DataFrame({'key': ['b', 'b', 'a', 'c', 'a', 'b'],
                  'data1': range(6)},
                  index=['a1','a2','a3','a4','a5','a6'])
  In[31]:df
  Out[31]: 
  </code></pre>
  
  <pre>
        data1 key
  a1      0   b
  a2      1   b
  a3      2   a
  a4      3   c
  a5      4   a
  a6      5   b
  </pre>
  
  <p>if I run </p>
  
  <pre><code>df.iloc[2,1]
  </code></pre>
  
  <p>it would return 'a'.
  the question is,  I just know the column label is 'key', how can I get the column number? then I can use df.iloc.</p>
  
  <p>you see, .ix is deprecated in pandas, else I would just use df.ix[2,'key'].</p>
  
  <p>I just know how the solution for the similar question: get column label from column number. for instance,</p>
  
  <pre><code>df.loc['a3',df.iloc[:,[1]].columns]
  </code></pre>