title: How to sum with missing values in Pandas?
body: <p>I want to sum Pandas Series objects, but I get weird results that seem not to be what the documentation says.</p>
  
  <p>In Pandas 0.19.2, the following code:</p>
  
  <pre><code>a = pd.Series({1: 2, 3: 4})
  b = pd.Series({3: 5, 4: 6})
  print(a + b)
  </code></pre>
  
  <p>gives me,</p>
  
  <pre><code>1    NaN
  3    9.0
  4    NaN
  dtype: float64
  </code></pre>
  
  <p>however, the <a href="https://pandas.pydata.org/pandas-docs/stable/missing_data.html" rel="nofollow noreferrer">documentation</a> says:</p>
  
  <blockquote>
    <p>When summing data, NA (missing) values will be treated as zero</p>
  </blockquote>
  
  <p>This seems to treat them as NaN rather than zeros.  I was expecting the output:</p>
  
  <pre><code>1    2.0
  3    9.0
  4    6.0
  dtype: float64
  </code></pre>
  
  <p>In my case the Series comes from <code>value_counts()</code> over several columns and I wanted to use <code>sum()</code> but it gives me NaN for all rows that don't have values in all columns, which is wrong.  There should be an integer for every row.</p>
  
  <p>Another mystery for me is why the result has dtype float:</p>
  
  <pre><code>a.dtype, b.dtype, (a+b).dtype
  </code></pre>
  
  <p>gives,</p>
  
  <pre><code>(dtype('int64'), dtype('int64'), dtype('float64'))
  </code></pre>
  
  <p>which is quite surprising to me.</p>
  
  <p>Edit: if I make sure that <code>a</code> and <code>b</code> have the same rows, then the resulting dtype is <code>int64</code>.  So the change to float is clearly just to allow for the NaN value, which is a bit shocking.</p>
  
  <p>Edit 2: Fix mistake in the expected output.</p>