title: Pandas compare column in same data frame and replace values based on comparison
body: <p>I have a excel sheet that consist of over 6000 rows. There are two column , &quot;IP Address CMDB&quot; that contain IP addresses and another column called &quot;IP Address LM&quot;.
  I am trying to look for IP address that belongs to &quot;IP Address CMDB&quot; in &quot;IP Address LM&quot; and if &quot;IP Address LM&quot; contain that IP address return ABCD.
  I could not attach excel sheet so I have attached screenshot of it.</p>
  <p><a href="https://i.stack.imgur.com/iCoZq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iCoZq.png" alt="enter image description here" /></a></p>
  <pre><code>for col in report:
      if col == &quot;IP Address CMDB&quot;:
          col_num = report[col]
          for num in col_num:
              if report[&quot;IP Address LM&quot;].str.contains(num):
                  print(&quot;ABCD&quot;)
  &lt;ipython-input-13-40cfae2bd937&gt;:5: UserWarning: This pattern has match groups. To actually get the groups, use str.extract.
    if report[&quot;IP Address LM&quot;].str.contains(num):
  ---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-13-40cfae2bd937&gt; in &lt;module&gt;
        3         col_num = report[col]
        4         for num in col_num:
  ----&gt; 5             if report[&quot;IP Address LM&quot;].str.contains(num):
        6                 print(&quot;ABCD&quot;)
        7 
  
  c:\users\rohit verma\appdata\local\programs\python\python39\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
     1535     @final
     1536     def __nonzero__(self):
  -&gt; 1537         raise ValueError(
     1538             f&quot;The truth value of a {type(self).__name__} is ambiguous. &quot;
     1539             &quot;Use a.empty, a.bool(), a.item(), a.any() or a.all().&quot;
  
  ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>