-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: Deprecate Series/Dataframe.to_dense/to_sparse #26684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a71737c
fc08e93
82c713d
39230d4
1e7c0e8
e68826c
20b8962
50d0534
933162d
dd1e6c2
c7f27fd
be14520
b12e447
2d4de51
eede9b8
0b08795
5182a1f
15909c5
104c12a
e713fb0
587b14f
1318676
9043e03
58c678a
ca14ac1
0c8f287
871ccff
a8f6c56
72aaca5
6a6e333
4e67856
4a3181b
a546a89
5fdb2f8
a627828
3d36430
9f888c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ def test_deprecated(): | |
|
||
|
||
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning") | ||
@pytest.mark.filterwarnings("ignore:Series.to_sparse:FutureWarning") | ||
@pytest.mark.filterwarnings("ignore:DataFrame.to_sparse:FutureWarning") | ||
class TestSparseDataFrame(SharedWithSparse): | ||
klass = SparseDataFrame | ||
|
||
|
@@ -348,6 +350,18 @@ def test_dense_to_sparse(self): | |
assert sdf.default_fill_value == 0 | ||
tm.assert_frame_equal(sdf.to_dense(), df) | ||
|
||
def test_deprecated_dense_to_sparse(self): | ||
# GH 26557 | ||
# Deprecated 0.25.0 | ||
|
||
df = pd.DataFrame({"A": [1, np.nan, 3]}) | ||
sparse_df = pd.SparseDataFrame({"A": [1, np.nan, 3]}) | ||
|
||
with tm.assert_produces_warning(FutureWarning, | ||
check_stacklevel=False): | ||
result = df.to_sparse() | ||
tm.assert_frame_equal(result, sparse_df) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you put this in a class where those warnings you want to check for are generally ignored. Does that work? (just wondering) Maybe we can also put it at the end of the file as a function instead of method, to avoid possible concerns about that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But since the tests are passing, this is probably fine ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually works fine, I wanted to keep both ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking, then that sounds good! |
||
|
||
def test_density(self): | ||
df = SparseSeries([nan, nan, nan, 0, 1, 2, 3, 4, 5, 6]) | ||
assert df.density == 0.7 | ||
|
@@ -1294,6 +1308,7 @@ def test_default_fill_value_with_no_data(self): | |
|
||
|
||
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning") | ||
@pytest.mark.filterwarnings("ignore:DataFrame.to_sparse:FutureWarning") | ||
class TestSparseDataFrameArithmetic: | ||
|
||
def test_numeric_op_scalar(self): | ||
|
@@ -1324,6 +1339,7 @@ def test_comparison_op_scalar(self): | |
|
||
|
||
@pytest.mark.filterwarnings("ignore:Sparse:FutureWarning") | ||
@pytest.mark.filterwarnings("ignore:DataFrame.to_sparse:FutureWarning") | ||
class TestSparseDataFrameAnalytics: | ||
|
||
def test_cumsum(self, float_frame): | ||
|
Uh oh!
There was an error while loading. Please reload this page.