Skip to content

Conversation

@sinhrks
Copy link
Member

@sinhrks sinhrks commented Apr 16, 2016

  • no existing issue
  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

Fixed following bugs on current master. Also, moved TestSparseArrayIndex to test_libsparse

1. shift

pd.SparseSeries([1, 2, 3], fill_value=0).shift(1)
# NameError: global name 'kwds' is not defined

pd.SparseSeries([1, 2, 3]).shift(1)
# TypeError: %d format: a number is required, not float

2. dtype

from pandas.sparse.array import IntIndex
arr = pd.SparseArray([1, 2], sparse_index=IntIndex(4, [1, 2]), dtype=None)
arr.dtype
# dtype('int64')

arr.values
# array([-9223372036854775808,                    1,                    2,
#        -9223372036854775808])

# Expected outputs
arr.dtype
# dtype('float64')

arr.values
# array([ nan,   1.,   2.,  nan])

@sinhrks sinhrks added Bug Indexing Related to indexing on series/frames, not to indexes themselves Dtype Conversions Unexpected or buggy dtype conversions Sparse Sparse Data Type labels Apr 16, 2016
@sinhrks sinhrks added this to the 0.18.1 milestone Apr 16, 2016
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would test the fill_value on all of the these (e.g. nan as the default, 0 on next example)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more tests in test_shift_nan. Is this what you mean?

Copy link
Contributor

@jreback jreback Apr 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I meant that you are asserting the fill_value in some of the tests here (as well as the dtype), but might want to assert fill_value for all (an example will be when we have nan fill values that we DO coerce on creation), e.g. say we have sparse datetimes (we don't really support this ATM)

pd.SparseArray([pd.NaT, pd.Timestamp('20130101'), pd.Timestamp('20130102'), pd.NaT], fill_value=np.nan)

Copy link
Member Author

@sinhrks sinhrks Apr 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback Thanks. ATM we can't create non-numeric SparseArray (#11856). Your example raises TypeError.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I get it. I just want a line that says self.assertTrue(np.isnan(arr.fill_value)) on the tests that don't have this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Added missing checks.

@jreback
Copy link
Contributor

jreback commented Apr 20, 2016

thanks!

sparse is really looking nice!

@sinhrks sinhrks deleted the sparse_shift branch April 20, 2016 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves Sparse Sparse Data Type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants