title: How to compare 2 different dataframe columns and add to 1 if equal in python?
body: <p>I have 2 dataframes <code>Table1</code> &amp; <code>Table2</code></p>
  <p><code>Table1</code> example output:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>CustomerID</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>CUST_3849502</td>
  </tr>
  <tr>
  <td>CUST_3935123</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><code>Table2</code> example output:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>CustomerID</th>
  <th>AccountID</th>
  <th>TimeCreated</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>CUST_3849502</td>
  <td>3823479@store</td>
  <td>2022-04-07T21:38:13.195641Z</td>
  </tr>
  <tr>
  <td>CUST_3935123</td>
  <td>343950347@store</td>
  <td>2022-04-07T21:38:13.647964Z</td>
  </tr>
  <tr>
  <td>CUST_4566768</td>
  <td>876876465@store</td>
  <td>2022-02-08T15:55:13.857347Z</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I'm trying to add <code>Table2[&quot;AccountID&quot;]</code> &amp; <code>Table2[&quot;TimeCreated&quot;]</code> to <code>Table1</code> if <code>Table1[&quot;CustomerID&quot;]</code> is in <code>Table2[&quot;CustomerID&quot;]</code></p>
  <p>So desired output of <code>Table1</code> is:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>CustomerID</th>
  <th>AccountID</th>
  <th>TimeCreated</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>CUST_3849502</td>
  <td>3823479@store</td>
  <td>2022-04-07T21:38:13.195641Z</td>
  </tr>
  <tr>
  <td>CUST_3935123</td>
  <td>343950347@store</td>
  <td>2022-04-07T21:38:13.647964Z</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I've tried:</p>
  <pre><code>for x in Table1[&quot;CustomerID&quot;]:
     if Table2[&quot;CustomerID&quot;] in x:
       Table1[&quot;AccountID&quot;] = Table2[&quot;AccountID&quot;]
       Table1[&quot;TimeCreated&quot;] = Table2[&quot;TimeCreated&quot;]
  </code></pre>
  <p>But keep getting <code>TypeError: 'in &lt;string&gt;' requires string as left operand, not Series</code> for the 2nd line</p>
  <p>Both columns are type <code>pandas.core.series.Series</code> so not sure what the issue is here, please help</p>