question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SparseSeries.__array__ only returns non-fills

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
jrebackcommented, Jan 15, 2018

@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)

0reactions
TomAugspurgercommented, Oct 17, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found