If statement in python Pandas
<p>I've a dataframe called family in pandas that I've created following an sql code. I've done all of it except this line. The sql code is the following </p>

<pre><code>SELECT IF(name Is Null, family.last_name, family.first_name) as family.NAME
from family
</code></pre>

<p>I've tried the following </p>

<pre><code>family['NAME']= np.where(family[family.name.isnull()],family.last_name, family.first_name)
</code></pre>

<p>But I'm not getting anywhere, any help is appreciated. The dataframe looks something like this </p>

<pre><code>name:    first_name:    last_name:
Peter    Peter          Smith
NaN      Phil           McGrath
Jack     Jack           Jones
NAN      Fred           Hogan 
</code></pre>

<p>I want it to get me a new column that would look like this </p>

<pre><code>NAME:
Peter
McGrath
Jack
Hogan
</code></pre>

<p>As MAXU said </p>

<pre><code>family['NAME'] = np.where(family.name.isnull(),family.last_name, family.first_name)
</code></pre>

<p>was the correct code</p>

python sql pandas