title: How to use apply for two pandas column including lists to return index in a list in one column using the element in another column?
body: <p>I have a pandas Dataframe with columns of "a" and "b". Column a has a list of values as a column value,  and column "b" has a list with a single value that might appear in column "a". I want to create a new column c based on column a and b that has the value of position of element in b that appears in column a values using apply. (c: (index of b in a)+1 )
  column b is always a list with one element or no element at all, column a can be in any length, but if it is empty, column b would be empty as well. column b element is expected to be in column a and I just want to find the position of first occurrence of it in column a.</p>
  
  <pre><code>a                         b                   c 
  
  
  ['1', '2', '5']          ['2']                2
  
  ['2','3','4']            ['4']                3
  ['2','3','4']            []                   0
  []                       []                   0
  ...
  </code></pre>
  
  <p>I wrote a for loop which works fine but it is pretty slow:</p>
  
  <pre><code>for i in range(0,len(df)):
  
      if len(df['a'][i])!=0:
          df['c'][i]=df['a'][i].index(*df['b'][i])+1 
      else:
          df['c'][i]=0
  </code></pre>
  
  <p>But I want to use apply to make it faster, the following does not work, any thoughts or suggestion would greatly be appreciated?</p>
  
  <pre><code>df['c']=df['a'].apply(df['a'].index(*df['b']))
  
  </code></pre>