title: Not able to use 'if x in list' using pandas
body: <p>I'm using <code>df.iterrows</code> to iterate through each member of a dataframe of four columns, which looks kind of like this:</p>
  
  <pre><code>A      B      C      D
  ----------------------
  A     ABC      
  B     ABD
  C     ABE
  D     ABC
  E     BC
  F     D
  </code></pre>
  
  <p>but only if the letter in column A is in a list that looks like:</p>
  
  <pre><code>slist = ['A', 'C', 'E']
  </code></pre>
  
  <p>My goal, is if any row has an A in column B, it'll mark column C with an X, and if it has a C, it'll mark column D with an X. If it has both, it'll mark both.</p>
  
  <p>In the end, it would look like this:</p>
  
  <pre><code>A     C      D
  ---------------
  A     X      X
  C     X      -
  E     -      X
  </code></pre>
  
  <p>So, my current code looks like this:</p>
  
  <pre><code>for index, x in df.iterrows():
  
      if x['A'] in slist:
          if 'A' in x['B'] and 'P' in x['B']:
              x['C'] = 'X'
              x['D'] = 'X'
          elif 'C' in x['B'] and 'A' not in x['B']:
              x['D'] = 'X'
          elif 'A' in x['B'] and 'C' not in x['B']:
              x['C'] = 'x'
      else:
          continue
  </code></pre>
  
  <p>but <code>if x['A'] in slist:</code> never works, and I always get columns C and D back completely blank. </p>
  
  <p>What am I missing that is causing this to happen? I've had the same problem on other projects, but have worked a way around it. This time, it's necessary to use a list and I can't seem to get it to work.</p>