title: Columns must be same length as key Error python
body: <p>I have 2 CSV files in file1 I have list of research groups names. in file2 I have list of the Research full name with location as wall. I want to join these 2 csv file if the have the words matches in them.</p>
  <p>Pandas ValueError: &quot;Columns must be same length as key&quot; I am using Jupyter Labs for this.</p>
  <p>&quot;df1[[&quot;f2_research_groups_names&quot;, &quot;f2_location&quot;]] = df1.apply(fn, axis=1)&quot;</p>
  <p>cvs row size for file1.csv 5000 data, and for file2.csv I have about 15,000</p>
  <p>file1.csv</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>research_groups_names_f1</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Chinese Academy of Sciences (CAS)</td>
  </tr>
  <tr>
  <td>CAS</td>
  </tr>
  <tr>
  <td>U-M</td>
  </tr>
  <tr>
  <td>UQ</td>
  </tr>
  <tr>
  <td>University of California, Los Angeles</td>
  </tr>
  <tr>
  <td>Harvard University</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>file2.csv</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>research_groups_names_f2</th>
  <th>Locatio_f2</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Chinese Academy of Sciences (CAS)</td>
  <td>China</td>
  </tr>
  <tr>
  <td>University of Michigan (U-M)</td>
  <td>USA</td>
  </tr>
  <tr>
  <td>The University of Queensland (UQ)</td>
  <td>USA</td>
  </tr>
  <tr>
  <td>University of California</td>
  <td>USA</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>file_output.csv</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>research_groups_names_f1</th>
  <th>research_groups_names_f2</th>
  <th>Locatio_f2</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Chinese Academy of Sciences</td>
  <td>Chinese Academy of Sciences(CAS)</td>
  <td>China</td>
  </tr>
  <tr>
  <td>CAS</td>
  <td>Chinese Academy of Sciences (CAS)</td>
  <td>China</td>
  </tr>
  <tr>
  <td>U-M</td>
  <td>University of Michigan (U-M)</td>
  <td>USA</td>
  </tr>
  <tr>
  <td>UQ</td>
  <td>The University of Queensland (UQ)</td>
  <td>Australia</td>
  </tr>
  <tr>
  <td>Harvard University</td>
  <td>Not found</td>
  <td>USA</td>
  </tr>
  <tr>
  <td>University of California, Los Angeles</td>
  <td>University of California</td>
  <td>USA</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre><code>import pandas as pd
      df1 = pd.read_csv('file1.csv')
      
      df2 = pd.read_csv('file1.csv')
  
      df1 = df1.add_prefix('f1_')
      df2 = df2.add_prefix('f2_')
  
  def fn(row):
      for _, n in df2.iterrows():
          if (
              n[&quot;research_groups_names_f1&quot;] == row[&quot;research_groups_names_f2&quot;]
              or row[&quot;research_groups_names_f1&quot;] in n[&quot;research_groups_names_f2&quot;]
          ):
              return n
  
  
  df1[[&quot;f2_research_groups_names&quot;, &quot;f2_location&quot;]] = df1.apply(fn, axis=1)
  df1 = df1.rename(columns={&quot;research_groups_names&quot;: &quot;f1_research_groups_names&quot;})
  print(df1)
  </code></pre>