title: Join values from one column to the another with replacing the second line in a cell in pandas
body: <p>I have two columns and want to join values from one column to the other. I want to join values from column "A" to column "B", but at the and I want in column "B" for each cell to be with two lines if a cell from column "B" is not empty and only with value from column "A" if a cell in column "B" is empty.</p>
  
  <p>Here is data frame</p>
  
  <p>df</p>
  
  <pre><code>  A      B
    Nr.1  18b
    Nr.1  
    Nr.1  18c\nNr.2\n
    Nr.1  18d\nNr.1
    Nr.2  
    Nr.2  20a\n
    Nr.2  20a\nNr.2
    Nr.3  20b\nNr.2\n
    Nr.3  
  </code></pre>
  
  <p>So, at the and I want:</p>
  
  <p>df</p>
  
  <pre><code>  A      B
    Nr.1  18b\nNr.1
    Nr.1  Nr.1
    Nr.1  18c\nNr.1
    Nr.1  18d\nNr.1
    Nr.2  Nr.2
    Nr.2  20a\nNr.2
    Nr.2  20a\nNr.2
    Nr.3  20b\nNr.2
    Nr.3  Nr.3
  </code></pre>
  
  <p>I tried with df['B'] = df[["B", "A"]].apply(lambda x: ''.join(x.dropna().astype(str)),axis=1) when I want to add values from column "A" and it works when the cell from column "B" ends with newline (\n)</p>
  
  <p>When I do not have the newline at the end of string then I use df['B'] = df[["B", "A"]].apply(lambda x: '\n'.join(x.dropna().astype(str)),axis=1)</p>
  
  <p>But the problem is when I already have two lines in the cell. I need to replace a value in the second line with the value from column "A", and at the end of the string should not be "\n".</p>
  
  <p>Is it some elegant way to solve this?
  I appreciate any help.</p>