pandas: SparseSeries.__array__ only returns non-fills

Code Sample, a copy-pastable example if possible

>>> np.array(pd.SparseSeries([0, 1], fill_value=0))
array([1])

Expected Output

array([0, 1])

this should really be consistent with Series rather than just returning the non-fill values (i.e. rather than being equivalent to np.array(ps.SparseArray([np.nan, 1])).

output of pd.show_versions()

Pandas 0.18.1

should alone be relevant.

Apologies I’ve not checked if this is fixed in master. Just passing on issues from scikit-learn/scikit-learn#7352.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 17 (17 by maintainers)

Most upvoted comments

@hexgnu this is a bit more complicated here, __array__ can/should return a dense view of the data, but you can handle the wrapping/unwrapping to a SparseSeries thru things like __array_wrap__ (which are defined inSeries)