IntegerArray + List returns ndarray · Issue #22962 · pandas-dev/pandas (original) (raw)
Right now, IntegerArary.__add__
calls np.asarray(other)
for list-like other. When other
is an actual list with missing values, we end up with a float ndarray.
In [2]: arr = pd.Series([1, None, 3], dtype='Int8').values
In [3]: arr + list(arr)
Out[3]: array([ 2., nan, 6.])
Compare with Non-NA values:
In [4]: arr = pd.Series([1, 2, 3], dtype='Int8').values
In [6]: arr + list(arr) Out[6]: IntegerArray([2, 4, 6], dtype='Int8')
In general, an IntegerArray + ndarray[float] should be a floating point ndarray,
In [10]: arr + np.array([1., 2., 3.]) Out[10]: array([2., 4., 6.])
Do we special case missing values here?