Better way to implement `df[m] = df[x] + df[y] + df[z]`
<p>I want to get the sum of three columns, the method I took is as follows:</p>

<pre><code>In [14]:

a_pd = pd.DataFrame({'a': np.arange(3),
                     'b': [5, 7, np.NAN],
                     'c': [2, 9, 0]})
a_pd
Out[14]:
a   b   c
0   0   5.0 2
1   1   7.0 9
2   2   NaN 0
In [18]:

b_pd = a_pd['a'] + a_pd['b'] + a_pd['c']
b_pd
Out[18]:
0     7.0
1    17.0
2     NaN
dtype: float64
</code></pre>

<p>But as you can see, NaN can not be excluded.
so I tried <code>np.add()</code>,but something wrong:</p>

<pre><code>In [19]:

b_pd = a_pd[['a', 'b', 'c']].apply(np.add, axis=1)
b_pd
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-19-f52f400573b4&gt; in &lt;module&gt;()
----&gt; 1 b_pd = a_pd[['a', 'b', 'c']].apply(np.add, axis=1)
      2 b_pd

F:\anaconda\lib\site-packages\pandas\core\frame.pyc in apply(self, func, axis, broadcast, raw, reduce, args, **kwds)
   4045 
   4046         if isinstance(f, np.ufunc):
-&gt; 4047             results = f(self.values)
   4048             return self._constructor(data=results, index=self.index,
   4049                                      columns=self.columns, copy=False)

ValueError: invalid number of arguments
</code></pre>

<p>So, I want to know how you fix this bug.</p>

<p>You can use the sum method of the DataFrame:</p>

<pre><code>a_pd.sum(axis=1)
Out: 
0     7.0
1    17.0
2     2.0
dtype: float64
</code></pre>

<p>If you want to specify columns:</p>

<pre><code>a_pd[['a', 'b', 'c']].sum(axis=1)
Out: 
0     7.0
1    17.0
2     2.0
dtype: float64
</code></pre>

python pandas apply