Code Sample
import pandas as pd
pd.Series([1,2,3]).add(pd.Series([100]), fill_value=0)
Problem description
The resulting dtype should be int (as the inputs and fill_value
are all ints), but it is float:
0 101.0
1 2.0
2 3.0
dtype: float64
Output of pd.show_versions()
python: 3.5.4.final.0
python-bits: 64
pandas: 0.20.3
numpy: 1.13.1
Comment From: jreback
aligned causes a shift to float64. We don't upcast automatically on fillna, becuase of perf (it can be non-cheap). So this is an unavoidable side affect of lack of good NA support in numpy.
In [1]: pd.Series([1,2,3]).align(pd.Series([100]))
Out[1]:
(0 1
1 2
2 3
dtype: int64, 0 100.0
1 NaN
2 NaN
dtype: float64)