API: Sparse Return Types (original) (raw)
The documentation of SparseArray.cumsum says it returns a Series, but that is not the case:
from pandas import SparseArray, np data = np.arange(10) s = SparseArray(data, fill_value=np.nan) type(s.cumsum()) <class 'pandas.sparse.array.SparseArray'>
s = SparseArray(data, fill_value=2) type(s.cumsum()) <class 'numpy.ndarray'>
Given that to_dense now returns self.values and ignores fill_value, this current behaviour in cumsum seems illogical and should probably just return SparseArray regardless. At the very least though, I think a documentation fix is in order.
EDIT: there is a similar issue with SparseSeries that should also be addressed