Skip to content

Commit 6a65cbc

Browse files
committed
SparseSeries unstack
1 parent b253674 commit 6a65cbc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

doc/source/whatsnew/v0.24.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ Other API Changes
11031103
- The order of the arguments of :func:`DataFrame.to_html` and :func:`DataFrame.to_string` is rearranged to be consistent with each other. (:issue:`23614`)
11041104
- :meth:`CategoricalIndex.reindex` now raises a ``ValueError`` if the target index is non-unique and not equal to the current index. It previously only raised if the target index was not of a categorical dtype (:issue:`23963`).
11051105
- :func:`Series.to_list` and :func:`Index.to_list` are now aliases of ``Series.tolist`` respectively ``Index.tolist`` (:issue:`8826`)
1106+
- The result of ``SparseSeries.unstack`` is now a :class:`DataFrame` with sparse values, rather than a :class:`SparseDataFrame` (issue:`24372`).
11061107

11071108
.. _whatsnew_0240.deprecations:
11081109

pandas/tests/sparse/test_reshape.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ def test_sparse_frame_unstack(sparse_df):
3535

3636
def test_sparse_series_unstack(sparse_df, multi_index3):
3737
frame = pd.SparseSeries(np.ones(3), index=multi_index3).unstack()
38-
tm.assert_sp_frame_equal(frame, sparse_df)
38+
39+
arr = np.array([1, np.nan, np.nan])
40+
arrays = {i: pd.SparseArray(np.roll(arr, i)) for i in range(3)}
41+
expected = pd.DataFrame(arrays)
42+
tm.assert_frame_equal(frame, expected)

0 commit comments

Comments
 (0)