How to add new column with handling nan value
<p>I have a dataframe like this</p>

<pre><code>    A   B
0   a   1
1   b   2
2   c   3
3   d  nan
4   e  nan
</code></pre>

<p>I would like to add column C like below</p>

<pre><code>    A   B    C
0   a   1    a1
1   b   2    b2
2   c   3    c3
3   d  nan   d
4   e  nan   e
</code></pre>

<p>So I tried </p>

<pre><code>df["C"]=df.A+df.B
</code></pre>

<p>but It returns </p>

<pre><code> C
a1
b2
c3
nan
nan
</code></pre>

<p>How can get correct result?</p>

<p>You can use <code>add</code> method with the <code>fill_value</code> parameter</p>

<pre><code>df['C'] = df.A.add(df.B, fill_value='')
df
</code></pre>

<p><a href="http://i.stack.imgur.com/JLttG.png" rel="nofollow"><img src="http://i.stack.imgur.com/JLttG.png" alt="enter image description here"></a></p>

python pandas