title: Merge rows in a Pandas Dataframe filling NaN values and removing duplicates
body: <p>I'm trying to clean a Python <code>Pandas dataframe</code> that contains dirty data with <strong>&quot;repeated&quot; (but not exactly duplicated)</strong> people information.</p>
  <pre><code>id  name    name2   name3   email
  1   A       A       A       email@gmail.com
  1   A       NaN     NaN     NaN
  NaN A       A       B       email@gmail.com
  NaN A       A       B       email@gmail.com
  1   A       A       B       NaN
  NaN A       A       A       email@gmail.com
  </code></pre>
  <p>Unfortunately I don't have a clear &quot;primary key&quot; since the column <code>id</code> is not always set and I have a list of different names (<code>name</code>,<code>name2</code>,<code>name3</code>) that don't match always (sometime I have the same <code>name</code> but different <code>name2</code>).
  I'd like to keep both these information, but removing duplicate rows and &quot;<strong>merging</strong>&quot; rows in order to remove the maximum number of NaN values, without loosing any king of information.</p>
  <p>The output should be that:</p>
  <pre><code>id  name    name2   name3   email
  1   A       A       A       email@gmail.com
  1   A       A       B       email@gmail.com
  </code></pre>
  <p>The second row is given by the merge between</p>
  <pre><code>NaN A       A       B       email@gmail.com
  1   A       A       B       NaN
  </code></pre>
  <p>in the original dataframe.</p>
  <p>(I already tried the solution here: <a href="https://stackoverflow.com/questions/67588957/how-can-i-merge-duplicate-rows-and-fill-the-nan-cells-with-the-values-from-the-o">How can I merge duplicate rows and fill the NaN cells with the values from the other row?</a> but without success)</p>
  <p>Thanks.</p>