title: Concatenating columns of lists containing NaNs in a dataframe
body: <p>I have a pandas df with two columns having either lists or NaN values. <strong>There are no rows having NaN in both columns</strong>. I want to create a third column that merges the values of the other two columns in the following way:-</p>
  
  <pre><code>if row df.a is NaN -&gt; df.c = df.b
  
  if row df.b is Nan -&gt; df.c = df.a
  
  else df.c = df.a + df.b
  </code></pre>
  
  <p>Input:-</p>
  
  <pre><code>df
                                   a                                    b
  0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  1   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  2   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  3   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  4   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  5   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  6   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  7   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                  NaN   
  8   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]  [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]   
  9   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]  [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]   
  10                             NaN  [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]   
  11                             NaN  [5, 6, 7, 8, 9, 10, 11, 12, 13, 14] 
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>df.c
  
  0   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  1   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  2   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  3   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  4   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  5   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  6   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  7   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]                                     
  8   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]   
  9   [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]   
  10  [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
  11  [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
  </code></pre>
  
  <p>I tried to use this nested condition with apply </p>
  
  <pre><code>df['c'] = df.apply(lambda x: x.a if x.b is float else (x.b if x.a is float else (x['a'] + x['b'])), axis = 1)
  </code></pre>
  
  <p>but is giving me this error :</p>
  
  <blockquote>
    <p>TypeError: ('can only concatenate list (not "float") to list', u'occurred at index 0').</p>
  </blockquote>
  
  <p>I am using ( and it's acutally working) </p>
  
  <pre><code>if x is float 
  </code></pre>
  
  <p>because is the only way I found to separate a list from a NaN value.</p>