title: Lambda function with for loop and if-else statement
body: <p>I have a dataframe <code>df</code> that looks like this</p>
  <pre><code>index       Posts                    clean_text
    0     Hi I am fine.              [Hi, I, am, fine]
    1     You are a piece of shit.   [You, are, a, piece, of, shit]
  .
  .
  .
  </code></pre>
  <p>I have a list named <code>corpus</code> that has 3000 foul words.</p>
  <p>I want to go through the column <code>clean_text</code> and add a new row <code>result</code> to the <code>df</code> by check a condition for all the rows. The condition is:
  if any one of the words of the list in any row of the column <code>clean_text</code> is present in the <code>corpus</code>, the column <code>result</code> will have the string <code>Irrelevant</code>, otherwise <code>Relevant</code>.</p>
  <p>Example: if any word of the list <code>[Hi, I, am, fine]</code> is present in the <code>corpus</code>, the column <code>result</code> will have <code>Irrelevant</code>, otherwise <code>relevant</code>. Since, this list dose not have any foul words, the output should be <code>relevant</code>.</p>
  <p>The desired output is :</p>
  <pre><code>index       Posts                    clean_text                       result
    0     Hi I am fine.              [Hi, I, am, fine]                  Relevant
    1     You are a piece of shit.   [You, are, a, piece, of, shit]     Irrelevant
  .
  .
  .
  </code></pre>
  <p>I want to do this using lambda function. I have done this so far-</p>
  <p><code>df['result'] = df['clean_text'].map(lambda x: [&quot;Relevant&quot; for w in x if w not in corpus])</code>
  Firstly, I am unable to write the <code>else</code> part here and secondly it is showing an undesirable output like below.</p>
  <pre><code>index       Posts                    clean_text                       result
    0     Hi I am fine.              [Hi, I, am, fine]                  [Relevant, Relevant, Relevant, Relevant]
    1     You are a piece of shit.   [You, are, a, piece, of, shit]     [Relevant, Relevant, Relevant,...]
  .
  .
  .
  </code></pre>
  <p>I also tried writing a ``for``` loop like this but it takes a lot of time:</p>
  <pre><code>for i in range(df.shape[0]):
      for word in df.loc[i]['clean_text']:
        if word in corpus:
          df['result'] = &quot;Irrelevant&quot;
          #break
        else:
          #continue
          df['result'] = &quot;Relevant&quot;
  </code></pre>
  <p>Kindly help me to get the desired output using lambda function.</p>