|
19 | 19 |
|
20 | 20 | from pandas.errors import PerformanceWarning
|
21 | 21 |
|
22 |
| -from pandas.core.dtypes.common import is_object_dtype |
23 |
| - |
24 | 22 | import pandas as pd
|
25 | 23 | from pandas import SparseDtype
|
26 | 24 | import pandas._testing as tm
|
@@ -159,10 +157,7 @@ def test_concat_mixed_dtypes(self, data):
|
159 | 157 | ],
|
160 | 158 | )
|
161 | 159 | def test_stack(self, data, columns):
|
162 |
| - with tm.assert_produces_warning( |
163 |
| - FutureWarning, check_stacklevel=False, match="astype from Sparse" |
164 |
| - ): |
165 |
| - super().test_stack(data, columns) |
| 160 | + super().test_stack(data, columns) |
166 | 161 |
|
167 | 162 | def test_concat_columns(self, data, na_value):
|
168 | 163 | self._check_unsupported(data)
|
@@ -385,33 +380,11 @@ def test_equals(self, data, na_value, as_series, box):
|
385 | 380 |
|
386 | 381 |
|
387 | 382 | class TestCasting(BaseSparseTests, base.BaseCastingTests):
|
388 |
| - def test_astype_object_series(self, all_data): |
389 |
| - # Unlike the base class, we do not expect the resulting Block |
390 |
| - # to be ObjectBlock / resulting array to be np.dtype("object") |
391 |
| - ser = pd.Series(all_data, name="A") |
392 |
| - with tm.assert_produces_warning(FutureWarning, match="astype from Sparse"): |
393 |
| - result = ser.astype(object) |
394 |
| - assert is_object_dtype(result.dtype) |
395 |
| - assert is_object_dtype(result._mgr.array.dtype) |
396 |
| - |
397 |
| - def test_astype_object_frame(self, all_data): |
398 |
| - # Unlike the base class, we do not expect the resulting Block |
399 |
| - # to be ObjectBlock / resulting array to be np.dtype("object") |
400 |
| - df = pd.DataFrame({"A": all_data}) |
401 |
| - |
402 |
| - with tm.assert_produces_warning(FutureWarning, match="astype from Sparse"): |
403 |
| - result = df.astype(object) |
404 |
| - assert is_object_dtype(result._mgr.arrays[0].dtype) |
405 |
| - |
406 |
| - # check that we can compare the dtypes |
407 |
| - comp = result.dtypes == df.dtypes |
408 |
| - assert not comp.any() |
409 |
| - |
410 | 383 | def test_astype_str(self, data):
|
411 |
| - with tm.assert_produces_warning(FutureWarning, match="astype from Sparse"): |
412 |
| - result = pd.Series(data[:5]).astype(str) |
413 |
| - expected_dtype = SparseDtype(str, str(data.fill_value)) |
414 |
| - expected = pd.Series([str(x) for x in data[:5]], dtype=expected_dtype) |
| 384 | + # pre-2.0 this would give a SparseDtype even if the user asked |
| 385 | + # for a non-sparse dtype. |
| 386 | + result = pd.Series(data[:5]).astype(str) |
| 387 | + expected = pd.Series([str(x) for x in data[:5]], dtype=object) |
415 | 388 | self.assert_series_equal(result, expected)
|
416 | 389 |
|
417 | 390 | @pytest.mark.xfail(raises=TypeError, reason="no sparse StringDtype")
|
|
0 commit comments