Skip to content

Commit f285272

Browse files
committed
some more
1 parent 7448795 commit f285272

File tree

3 files changed

+4
-53
lines changed

3 files changed

+4
-53
lines changed

pandas/core/arrays/sparse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,10 +2046,10 @@ def to_coo(self, row_levels=(0,), column_levels=(1,), sort_labels=False):
20462046
(2, 1, 'b', 0),
20472047
(2, 1, 'b', 1)],
20482048
names=['A', 'B', 'C', 'D'])
2049-
>>> ss = s.to_sparse()
2050-
>>> A, rows, columns = ss.to_coo(row_levels=['A', 'B'],
2051-
column_levels=['C', 'D'],
2052-
sort_labels=True)
2049+
>>> ss = s.astype("Sparse")
2050+
>>> A, rows, columns = ss.sparse.to_coo(row_levels=['A', 'B'],
2051+
... column_levels=['C', 'D'],
2052+
... sort_labels=True)
20532053
>>> A
20542054
<3x4 sparse matrix of type '<class 'numpy.float64'>'
20552055
with 3 stored elements in COOrdinate format>

pandas/tests/arrays/sparse/test_arithmetics.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ def mix(request):
2121
return request.param
2222

2323

24-
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
25-
@pytest.mark.filterwarnings("ignore:Series.to_sparse:FutureWarning")
2624
class TestSparseArrayArithmetics:
2725

2826
_base = np.array

pandas/tests/io/pytables/test_pytables.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@
7171
ignore_natural_naming_warning = pytest.mark.filterwarnings(
7272
"ignore:object name:tables.exceptions.NaturalNameWarning"
7373
)
74-
ignore_sparse = pytest.mark.filterwarnings("ignore:Sparse:FutureWarning")
75-
ignore_dataframe_tosparse = pytest.mark.filterwarnings(
76-
"ignore:DataFrame.to_sparse:FutureWarning"
77-
)
78-
ignore_series_tosparse = pytest.mark.filterwarnings(
79-
"ignore:Series.to_sparse:FutureWarning"
80-
)
8174

8275
# contextmanager to ensure the file cleanup
8376

@@ -2677,40 +2670,6 @@ def test_overwrite_node(self):
26772670

26782671
tm.assert_series_equal(store["a"], ts)
26792672

2680-
@ignore_sparse
2681-
@ignore_dataframe_tosparse
2682-
def test_sparse_with_compression(self):
2683-
2684-
# GH 2931
2685-
2686-
# make sparse dataframe
2687-
arr = np.random.binomial(n=1, p=0.01, size=(1000, 10))
2688-
df = DataFrame(arr).to_sparse(fill_value=0)
2689-
2690-
# case 1: store uncompressed
2691-
self._check_double_roundtrip(
2692-
df, tm.assert_frame_equal, compression=False, check_frame_type=True
2693-
)
2694-
2695-
# case 2: store compressed (works)
2696-
self._check_double_roundtrip(
2697-
df, tm.assert_frame_equal, compression="zlib", check_frame_type=True
2698-
)
2699-
2700-
# set one series to be completely sparse
2701-
df[0] = np.zeros(1000)
2702-
2703-
# case 3: store df with completely sparse series uncompressed
2704-
self._check_double_roundtrip(
2705-
df, tm.assert_frame_equal, compression=False, check_frame_type=True
2706-
)
2707-
2708-
# case 4: try storing df with completely sparse series compressed
2709-
# (fails)
2710-
self._check_double_roundtrip(
2711-
df, tm.assert_frame_equal, compression="zlib", check_frame_type=True
2712-
)
2713-
27142673
def test_select(self):
27152674

27162675
with ensure_clean_store(self.path) as store:
@@ -3858,8 +3817,6 @@ def test_start_stop_multiple(self):
38583817
expected = df.loc[[0], ["foo", "bar"]]
38593818
tm.assert_frame_equal(result, expected)
38603819

3861-
@ignore_sparse
3862-
@ignore_dataframe_tosparse
38633820
def test_start_stop_fixed(self):
38643821

38653822
with ensure_clean_store(self.path) as store:
@@ -3899,10 +3856,6 @@ def test_start_stop_fixed(self):
38993856
df = tm.makeDataFrame()
39003857
df.iloc[3:5, 1:3] = np.nan
39013858
df.iloc[8:10, -2] = np.nan
3902-
dfs = df.to_sparse()
3903-
store.put("dfs", dfs)
3904-
with pytest.raises(NotImplementedError):
3905-
store.select("dfs", start=0, stop=5)
39063859

39073860
def test_select_filter_corner(self):
39083861

0 commit comments

Comments
 (0)