From 920aa7e5bc43b0d65b20c5504ba1f6042b0350c1 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 3 Jul 2023 19:02:45 +0200 Subject: [PATCH] DEPR: start with Deprecation instead of FutureWarning for NDFrame._data --- pandas/core/generic.py | 2 +- pandas/tests/frame/test_api.py | 2 +- pandas/tests/generic/test_generic.py | 2 +- pandas/tests/series/test_api.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index b806ddbaa89ba..f049e9d479b26 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -506,7 +506,7 @@ def _data(self): warnings.warn( f"{type(self).__name__}._data is deprecated and will be removed in " "a future version. Use public APIs instead.", - FutureWarning, + DeprecationWarning, stacklevel=find_stack_level(), ) return self._mgr diff --git a/pandas/tests/frame/test_api.py b/pandas/tests/frame/test_api.py index e0d9d6c281fd5..7cf1c56d9342e 100644 --- a/pandas/tests/frame/test_api.py +++ b/pandas/tests/frame/test_api.py @@ -379,6 +379,6 @@ def test_inspect_getmembers(self): df = DataFrame() msg = "DataFrame._data is deprecated" with tm.assert_produces_warning( - FutureWarning, match=msg, check_stacklevel=False + DeprecationWarning, match=msg, check_stacklevel=False ): inspect.getmembers(df) diff --git a/pandas/tests/generic/test_generic.py b/pandas/tests/generic/test_generic.py index acc1a8c2e1d05..6226f97c73f92 100644 --- a/pandas/tests/generic/test_generic.py +++ b/pandas/tests/generic/test_generic.py @@ -307,7 +307,7 @@ def test_copy_and_deepcopy(self, frame_or_series, shape, func): def test_data_deprecated(self, frame_or_series): obj = frame_or_series() msg = "(Series|DataFrame)._data is deprecated" - with tm.assert_produces_warning(FutureWarning, match=msg): + with tm.assert_produces_warning(DeprecationWarning, match=msg): mgr = obj._data assert mgr is obj._mgr diff --git a/pandas/tests/series/test_api.py b/pandas/tests/series/test_api.py index e4e276af121f9..7d70206585be4 100644 --- a/pandas/tests/series/test_api.py +++ b/pandas/tests/series/test_api.py @@ -172,7 +172,7 @@ def test_inspect_getmembers(self): ser = Series(dtype=object) msg = "Series._data is deprecated" with tm.assert_produces_warning( - FutureWarning, match=msg, check_stacklevel=False + DeprecationWarning, match=msg, check_stacklevel=False ): inspect.getmembers(ser)