title: reduce the time complexity for python for loop
body: <p>I have python data frame with the following columns:</p>
  
  <pre><code>Index([u'Academic Period', u'Academic Period Desc', u'Student ID',
         u'Subject', u'Course Number', u'Course Reference Number',
         u'Course Identification', u'Schedule Type', u'Instructor's ID',
         u'Highest Degree', u'Highest Degree Code',
         u'Instructor Position Employee Group'],
        dtype='object')
  </code></pre>
  
  <p>I'm now trying to loop by rows, check and compare two column values:</p>
  
  <pre><code>for i in df['Student ID']:
      if df['Course Reference Number'] &gt;= 50000:
          if df['Highest Degree Code'] &lt;= 7:
              print df["Instructor's ID"]
      else:
          if df['Highest Degree Code'] &lt;= 6:
              print df["Instructor's ID"]
  </code></pre>
  
  <p>I have 910,000+ rows in my file and it's taking too long to loop through. </p>
  
  <p>Can i reduce the time complexity from O(n) to lower(with any possible algorithm)?</p>
  
  <p>Thanks!</p>