SparseSeries.__array__ only returns non-fills
See original GitHub issueCode 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.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:17 (17 by maintainers)
Top Results From Across the Web
Sparse data structures — pandas 1.5.2 documentation
arrays.SparseArray is a ExtensionArray for storing an array of sparse values ... It is a 1-dimensional ndarray-like object storing only values distinct from ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 aSparseSeries
thru things like__array_wrap__
(which are defined inSeries
)This was fixed by https://github.com/pandas-dev/pandas/pull/22325