Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API/BUG: SparseSeries.shape ignores fill_value #10452

Closed
sinhrks opened this issue Jun 27, 2015 · 3 comments
Closed

API/BUG: SparseSeries.shape ignores fill_value #10452

sinhrks opened this issue Jun 27, 2015 · 3 comments
Labels
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented Jun 27, 2015

SparseSeries.shape seems to return incorrect result ignoring shapes filled by fill_value.

s = pd.SparseSeries([0, 0, 1, 0], fill_value=0)
s
#0    0
#1    0
#2    1
#3    0
# dtype: int64
# BlockIndex
# Block locations: array([2], dtype=int32)
# Block lengths: array([1], dtype=int32)

len(s)
#4

# must be (4, )?
s.shape
# (1,)

# OK
s._data.shape
# (4,)
@sinhrks sinhrks added Bug API Design Sparse Sparse Data Type labels Jun 27, 2015
@jreback
Copy link
Contributor

jreback commented Jun 27, 2015

This refers to the shape of the sparse values, not the shape of the series itself.

In [19]: s._data.blocks[0].sp_values
Out[19]: array([1])

In [20]: s._data.blocks[0].sp_values.shape
Out[20]: (1,)

@sinhrks
Copy link
Member Author

sinhrks commented Jun 27, 2015

I see. This is a spec and not be fixed?

May be a option to fix docstring to say underlying means sparse values.

help(pd.SparseSeries.shape)
# return a tuple of the shape of the underlying data

@jreback
Copy link
Contributor

jreback commented Jun 27, 2015

I don't remember where exactly this is used and whether its just user-facing. If its user facing only, then it should be consistent and return the shape of a densified frame, and we should have a sparse_shape or something. I am not sure what this really should do. If you want to experiment and report back would be gr8.

@jreback jreback added this to the 0.18.1 milestone Mar 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants