BUG: ufunc is not applied to sparse.fill_value by sinhrks · Pull Request #13853 · pandas-dev/pandas (original) (raw)

When ufunc is applied to sparse, it is not applied to fill_value. Thus results are incorrect.

np.abs(pd.SparseArray([1, -2, -1], fill_value=-2))
# [1.0, -2, 1.0]
# Fill: -2
# IntIndex
# Indices: array([0, 2], dtype=int32)

np.add(pd.SparseArray([1, -2, -1], fill_value=-2), 1)
# [2.0, -2, 0.0]
# Fill: -2
# IntIndex
# Indices: array([0, 2], dtype=int32)