title: Python Pandas Conditional Only Executes First "If" Statement
body: <p>I have a dataset 'df' like so:</p>
  
  <pre><code>a     b     c    e  f  g
  1     Nan   Nan  2  3  4
  Nan   1     Nan  2  3  4
  Nan   Nan   1    2  3  4
  </code></pre>
  
  <p>I want to create a new column 'd' in my dataframe 'df' like so:</p>
  
  <pre><code>   a     b     c    d  e  f  g 
     1     Nan   Nan  1  2  3  4
     Nan   1     Nan  1  2  3  4
     Nan   Nan   1    1  2  3  4
  </code></pre>
  
  <p>So basically, 'd' is the amalgamation of columns 'a', 'b', and 'c' for any non-NaN values those three columns have. Between 'a', 'b', and 'c', if one column is non-NaN, the other columns are NaN. I need columns 'e', 'f', and 'g' in my dataset, but they do not have anything to do with constructing column 'd'</p>
  
  <p>I created this function below:</p>
  
  <pre><code>def func(df):
      if df['a'] is not None:
          return df['a']
      if df['b'] is not None:
          return df['b']
      if df['c'] is not None:
          return df['c']
  </code></pre>
  
  <p>and then used <code>concatenated_df['d']=concatenated_df.apply(func, axis=1)</code> to apply the conditional statements for each row of the dataframe. However, I am only getting the first if statement to successfully execute. The rest returns NaN values to the new column 'd'</p>
  
  <p>I also tried modifying the function to </p>
  
  <pre><code>def func(df):
      if df['a'] is not None:
          return df['a']
      elif df['b'] is not None:
          return df['b']
      elif df['c'] is not None:
          return df['c']
  </code></pre>
  
  <p>but it still only executed the first conditional statement</p>