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

Comments

Projects
None yet
2 participants
@sinhrks
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,)
@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Jun 27, 2015

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@sinhrks

sinhrks Jun 27, 2015

Member

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
Member

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

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Jun 27, 2015

Contributor

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.

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.

@sinhrks sinhrks referenced this issue Mar 30, 2016

Closed

BUG: SparseSeries.shape ignores fill_value #12742

4 of 4 tasks complete

@jreback jreback added this to the 0.18.1 milestone Mar 30, 2016

@jreback jreback closed this in b550acc Mar 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment