Skip to content

Commit

Permalink
Fixed Series[sparse].to_sparse
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Aug 16, 2018
1 parent a4369c2 commit 608b499
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ Sparse
^^^^^^

- Updating a boolean, datetime, or timedelta column to be Sparse now works (:issue:`22367`)
- Bug in :meth:`Series.to_sparse` with Series already holding sparse data not constructing properly (:issue:`22389`)


Build Changes
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/sparse/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,3 +1499,11 @@ def test_constructor_dict_datetime64_index(datetime_type):
expected = SparseSeries(values, map(pd.Timestamp, dates))

tm.assert_sp_series_equal(result, expected)


def test_to_sparse():
# https://github.com/pandas-dev/pandas/issues/22389
arr = pd.SparseArray([1, 2, None, 3])
result = pd.Series(arr).to_sparse()
assert len(result) == 4
tm.assert_sp_array_equal(result.values, arr)

0 comments on commit 608b499

Please sign in to comment.