Skip to content

Commit 238db69

Browse files
committed
round 4
1 parent f61b5e3 commit 238db69

File tree

8 files changed

+7
-204
lines changed

8 files changed

+7
-204
lines changed

doc/source/whatsnew/v1.0.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ Deprecations
7878

7979
Removal of prior version deprecations/changes
8080
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81+
82+
- Removed ``SparseSeries`` and ``SparseDataFrame`` (:issue:``)
8183
- Removed the previously deprecated :meth:`Series.get_value`, :meth:`Series.set_value`, :meth:`DataFrame.get_value`, :meth:`DataFrame.set_value` (:issue:`17739`)
8284
- Changed the the default value of `inplace` in :meth:`DataFrame.set_index` and :meth:`Series.set_axis`. It now defaults to False (:issue:`27600`)
8385
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)

pandas/tests/frame/test_indexing.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,13 +2145,6 @@ def test_loc_duplicates(self):
21452145
df.loc[trange[bool_idx], "A"] += 6
21462146
tm.assert_frame_equal(df, expected)
21472147

2148-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
2149-
def test_iloc_sparse_propegate_fill_value(self):
2150-
from pandas.core.sparse.api import SparseDataFrame
2151-
2152-
df = SparseDataFrame({"A": [999, 1]}, default_fill_value=999)
2153-
assert len(df["A"].sp_values) == len(df.iloc[:, 0].sp_values)
2154-
21552148
def test_iat(self, float_frame):
21562149

21572150
for i, row in enumerate(float_frame.index):

pandas/tests/io/generate_legacy_storage_files.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@
5353
Period,
5454
RangeIndex,
5555
Series,
56-
SparseDataFrame,
57-
SparseSeries,
5856
Timestamp,
59-
bdate_range,
6057
date_range,
6158
period_range,
6259
timedelta_range,
@@ -89,47 +86,6 @@
8986
_loose_version = LooseVersion(pandas.__version__)
9087

9188

92-
def _create_sp_series():
93-
nan = np.nan
94-
95-
# nan-based
96-
arr = np.arange(15, dtype=np.float64)
97-
arr[7:12] = nan
98-
arr[-1:] = nan
99-
100-
bseries = SparseSeries(arr, kind="block")
101-
bseries.name = "bseries"
102-
return bseries
103-
104-
105-
def _create_sp_tsseries():
106-
nan = np.nan
107-
108-
# nan-based
109-
arr = np.arange(15, dtype=np.float64)
110-
arr[7:12] = nan
111-
arr[-1:] = nan
112-
113-
date_index = bdate_range("1/1/2011", periods=len(arr))
114-
bseries = SparseSeries(arr, index=date_index, kind="block")
115-
bseries.name = "btsseries"
116-
return bseries
117-
118-
119-
def _create_sp_frame():
120-
nan = np.nan
121-
122-
data = {
123-
"A": [nan, nan, nan, 0, 1, 2, 3, 4, 5, 6],
124-
"B": [0, 1, 2, nan, nan, nan, 3, 4, 5, 6],
125-
"C": np.arange(10).astype(np.int64),
126-
"D": [0, 1, 2, 3, 4, 5, nan, nan, nan, nan],
127-
}
128-
129-
dates = bdate_range("1/1/2011", periods=10)
130-
return SparseDataFrame(data, index=dates)
131-
132-
13389
def create_data():
13490
""" create the pickle/msgpack data """
13591

@@ -287,8 +243,6 @@ def create_data():
287243
index=index,
288244
scalars=scalars,
289245
mi=mi,
290-
sp_series=dict(float=_create_sp_series(), ts=_create_sp_tsseries()),
291-
sp_frame=dict(float=_create_sp_frame()),
292246
cat=cat,
293247
timestamp=timestamp,
294248
offsets=off,
@@ -308,8 +262,6 @@ def _u(x):
308262
def create_msgpack_data():
309263
data = create_data()
310264
# Not supported
311-
del data["sp_series"]
312-
del data["sp_frame"]
313265
del data["series"]["cat"]
314266
del data["series"]["period"]
315267
del data["frame"]["cat_onecol"]

pandas/tests/io/test_packers.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -585,49 +585,6 @@ def test_dataframe_duplicate_column_names(self):
585585
assert_frame_equal(result_3, expected_3)
586586

587587

588-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
589-
@pytest.mark.filterwarnings("ignore:Series.to_sparse:FutureWarning")
590-
@pytest.mark.filterwarnings("ignore:DataFrame.to_sparse:FutureWarning")
591-
@pytest.mark.filterwarnings("ignore:.*msgpack:FutureWarning")
592-
class TestSparse(TestPackers):
593-
def _check_roundtrip(self, obj, comparator, **kwargs):
594-
595-
# currently these are not implemetned
596-
# i_rec = self.encode_decode(obj)
597-
# comparator(obj, i_rec, **kwargs)
598-
msg = r"msgpack sparse (series|frame) is not implemented"
599-
with pytest.raises(NotImplementedError, match=msg):
600-
self.encode_decode(obj)
601-
602-
def test_sparse_series(self):
603-
604-
s = tm.makeStringSeries()
605-
s[3:5] = np.nan
606-
ss = s.to_sparse()
607-
self._check_roundtrip(ss, tm.assert_series_equal, check_series_type=True)
608-
609-
ss2 = s.to_sparse(kind="integer")
610-
self._check_roundtrip(ss2, tm.assert_series_equal, check_series_type=True)
611-
612-
ss3 = s.to_sparse(fill_value=0)
613-
self._check_roundtrip(ss3, tm.assert_series_equal, check_series_type=True)
614-
615-
def test_sparse_frame(self):
616-
617-
s = tm.makeDataFrame()
618-
s.loc[3:5, 1:3] = np.nan
619-
s.loc[8:10, -2] = np.nan
620-
ss = s.to_sparse()
621-
622-
self._check_roundtrip(ss, tm.assert_frame_equal, check_frame_type=True)
623-
624-
ss2 = s.to_sparse(kind="integer")
625-
self._check_roundtrip(ss2, tm.assert_frame_equal, check_frame_type=True)
626-
627-
ss3 = s.to_sparse(fill_value=0)
628-
self._check_roundtrip(ss3, tm.assert_frame_equal, check_frame_type=True)
629-
630-
631588
@pytest.mark.filterwarnings("ignore:.*msgpack:FutureWarning")
632589
class TestCompression(TestPackers):
633590
"""See https://github.com/pandas-dev/pandas/pull/9783

pandas/tests/reshape/test_reshape.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def test_dataframe_dummies_subset(self, df, sparse):
273273
expected[["C"]] = df[["C"]]
274274
if sparse:
275275
cols = ["from_A_a", "from_A_b"]
276-
expected[cols] = expected[cols].apply(lambda x: pd.SparseSeries(x))
276+
expected[cols] = expected[cols].astype(pd.SparseDtype("uint8", 0))
277277
assert_frame_equal(result, expected)
278278

279279
def test_dataframe_dummies_prefix_sep(self, df, sparse):
@@ -292,7 +292,7 @@ def test_dataframe_dummies_prefix_sep(self, df, sparse):
292292
expected = expected[["C", "A..a", "A..b", "B..b", "B..c"]]
293293
if sparse:
294294
cols = ["A..a", "A..b", "B..b", "B..c"]
295-
expected[cols] = expected[cols].apply(lambda x: pd.SparseSeries(x))
295+
expected[cols] = expected[cols].astype(pd.SparseDtype("uint8", 0))
296296

297297
assert_frame_equal(result, expected)
298298

@@ -329,7 +329,7 @@ def test_dataframe_dummies_prefix_dict(self, sparse):
329329
columns = ["from_A_a", "from_A_b", "from_B_b", "from_B_c"]
330330
expected[columns] = expected[columns].astype(np.uint8)
331331
if sparse:
332-
expected[columns] = expected[columns].apply(lambda x: pd.SparseSeries(x))
332+
expected[columns] = expected[columns].astype(pd.SparseDtype("uint8", 0))
333333

334334
assert_frame_equal(result, expected)
335335

@@ -495,7 +495,7 @@ def test_dataframe_dummies_drop_first_with_categorical(self, df, sparse, dtype):
495495
expected = expected[["C", "A_b", "B_c", "cat_y"]]
496496
if sparse:
497497
for col in cols:
498-
expected[col] = pd.SparseSeries(expected[col])
498+
expected[col] = pd.SparseArray(expected[col])
499499
assert_frame_equal(result, expected)
500500

501501
def test_dataframe_dummies_drop_first_with_na(self, df, sparse):
@@ -517,7 +517,7 @@ def test_dataframe_dummies_drop_first_with_na(self, df, sparse):
517517
expected = expected.sort_index(axis=1)
518518
if sparse:
519519
for col in cols:
520-
expected[col] = pd.SparseSeries(expected[col])
520+
expected[col] = pd.SparseArray(expected[col])
521521

522522
assert_frame_equal(result, expected)
523523

pandas/tests/series/test_api.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ def test_sort_index_name(self):
131131
result = self.ts.sort_index(ascending=False)
132132
assert result.name == self.ts.name
133133

134-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
135-
@pytest.mark.filterwarnings("ignore:Series.to_sparse:FutureWarning")
136-
def test_to_sparse_pass_name(self):
137-
result = self.ts.to_sparse()
138-
assert result.name == self.ts.name
139-
140134
def test_constructor_dict(self):
141135
d = {"a": 0.0, "b": 1.0, "c": 2.0}
142136
result = self.series_klass(d)

pandas/tests/series/test_combine_concat.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ def test_combine_first_dt_tz_values(self, tz_naive_fixture):
218218
exp = pd.Series(exp_vals, name="ser1")
219219
assert_series_equal(exp, result)
220220

221-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
222-
@pytest.mark.filterwarnings("ignore:Series.to_sparse:FutureWarning")
223221
def test_concat_empty_series_dtypes(self):
224222

225223
# booleans
@@ -273,39 +271,6 @@ def test_concat_empty_series_dtypes(self):
273271
== "object"
274272
)
275273

276-
# sparse
277-
# TODO: move?
278-
result = pd.concat(
279-
[Series(dtype="float64").to_sparse(), Series(dtype="float64").to_sparse()]
280-
)
281-
assert result.dtype == "Sparse[float64]"
282-
283-
# GH 26705 - Assert .ftype is deprecated
284-
with tm.assert_produces_warning(FutureWarning):
285-
assert result.ftype == "float64:sparse"
286-
287-
result = pd.concat(
288-
[Series(dtype="float64").to_sparse(), Series(dtype="float64")]
289-
)
290-
# TODO: release-note: concat sparse dtype
291-
expected = pd.core.sparse.api.SparseDtype(np.float64)
292-
assert result.dtype == expected
293-
294-
# GH 26705 - Assert .ftype is deprecated
295-
with tm.assert_produces_warning(FutureWarning):
296-
assert result.ftype == "float64:sparse"
297-
298-
result = pd.concat(
299-
[Series(dtype="float64").to_sparse(), Series(dtype="object")]
300-
)
301-
# TODO: release-note: concat sparse dtype
302-
expected = pd.core.sparse.api.SparseDtype("object")
303-
assert result.dtype == expected
304-
305-
# GH 26705 - Assert .ftype is deprecated
306-
with tm.assert_produces_warning(FutureWarning):
307-
assert result.ftype == "object:sparse"
308-
309274
def test_combine_first_dt64(self):
310275
from pandas.core.tools.datetimes import to_datetime
311276

pandas/tests/series/test_missing.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pytz
77

88
from pandas._libs.tslib import iNaT
9-
from pandas.errors import PerformanceWarning
109
import pandas.util._test_decorators as td
1110

1211
import pandas as pd
@@ -992,65 +991,6 @@ def test_series_fillna_limit(self):
992991
expected[:3] = np.nan
993992
assert_series_equal(result, expected)
994993

995-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
996-
@pytest.mark.filterwarnings("ignore:Series.to_sparse:FutureWarning")
997-
def test_sparse_series_fillna_limit(self):
998-
index = np.arange(10)
999-
s = Series(np.random.randn(10), index=index)
1000-
1001-
ss = s[:2].reindex(index).to_sparse()
1002-
# TODO: what is this test doing? why are result an expected
1003-
# the same call to fillna?
1004-
with tm.assert_produces_warning(
1005-
PerformanceWarning, raise_on_extra_warnings=False
1006-
):
1007-
# TODO: release-note fillna performance warning
1008-
result = ss.fillna(method="pad", limit=5)
1009-
expected = ss.fillna(method="pad", limit=5)
1010-
expected = expected.to_dense()
1011-
expected[-3:] = np.nan
1012-
expected = expected.to_sparse()
1013-
assert_series_equal(result, expected)
1014-
1015-
ss = s[-2:].reindex(index).to_sparse()
1016-
with tm.assert_produces_warning(
1017-
PerformanceWarning, raise_on_extra_warnings=False
1018-
):
1019-
result = ss.fillna(method="backfill", limit=5)
1020-
expected = ss.fillna(method="backfill")
1021-
expected = expected.to_dense()
1022-
expected[:3] = np.nan
1023-
expected = expected.to_sparse()
1024-
assert_series_equal(result, expected)
1025-
1026-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
1027-
@pytest.mark.filterwarnings("ignore:Series.to_sparse:FutureWarning")
1028-
def test_sparse_series_pad_backfill_limit(self):
1029-
index = np.arange(10)
1030-
s = Series(np.random.randn(10), index=index)
1031-
s = s.to_sparse()
1032-
1033-
result = s[:2].reindex(index, method="pad", limit=5)
1034-
with tm.assert_produces_warning(
1035-
PerformanceWarning, raise_on_extra_warnings=False
1036-
):
1037-
expected = s[:2].reindex(index).fillna(method="pad")
1038-
expected = expected.to_dense()
1039-
expected[-3:] = np.nan
1040-
expected = expected.to_sparse()
1041-
assert_series_equal(result, expected)
1042-
1043-
result = s[-2:].reindex(index, method="backfill", limit=5)
1044-
with tm.assert_produces_warning(
1045-
PerformanceWarning, raise_on_extra_warnings=False
1046-
):
1047-
expected = s[-2:].reindex(index).fillna(method="backfill")
1048-
expected = expected.to_dense()
1049-
expected[:3] = np.nan
1050-
expected = expected.to_sparse()
1051-
assert_series_equal(result, expected)
1052-
1053-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
1054994
def test_series_pad_backfill_limit(self):
1055995
index = np.arange(10)
1056996
s = Series(np.random.randn(10), index=index)

0 commit comments

Comments
 (0)