Skip to content

Commit c26c49d

Browse files
authored
DEPR: change Panel DeprecationWarning -> FutureWarning (#19247)
closes #18324
1 parent ec79392 commit c26c49d

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

doc/source/whatsnew/v0.23.0.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,34 @@ If installed, we now require:
225225
| openpyxl | 2.4.0 | |
226226
+-----------------+-----------------+----------+
227227

228+
.. _whatsnew_0230.api_breaking.deprecate_panel:
229+
230+
Deprecate Panel
231+
^^^^^^^^^^^^^^^
232+
233+
``Panel`` was deprecated in the 0.20.x release, showing as a ``DeprecationWarning``. Using ``Panel`` will now show a ``FutureWarning``. The recommended way to represent 3-D data are
234+
with a ``MultiIndex`` on a ``DataFrame`` via the :meth:`~Panel.to_frame` or with the `xarray package <http://xarray.pydata.org/en/stable/>`__. Pandas
235+
provides a :meth:`~Panel.to_xarray` method to automate this conversion. For more details see :ref:`Deprecate Panel <dsintro.deprecate_panel>` documentation. (:issue:`13563`, :issue:`18324`).
236+
237+
.. ipython:: python
238+
:okwarning:
239+
240+
p = tm.makePanel()
241+
p
242+
243+
Convert to a MultiIndex DataFrame
244+
245+
.. ipython:: python
246+
247+
p.to_frame()
248+
249+
Convert to an xarray DataArray
250+
251+
.. ipython:: python
252+
:okwarning:
253+
254+
p.to_xarray()
255+
228256

229257
Build Changes
230258
^^^^^^^^^^^^^
@@ -291,6 +319,7 @@ Deprecations
291319
- :func:`read_excel` has deprecated the ``skip_footer`` parameter. Use ``skipfooter`` instead (:issue:`18836`)
292320
- The ``is_copy`` attribute is deprecated and will be removed in a future version (:issue:`18801`).
293321

322+
294323
.. _whatsnew_0230.prior_deprecations:
295324

296325
Removal of prior version deprecations/changes

pandas/core/panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def __init__(self, data=None, items=None, major_axis=None, minor_axis=None,
151151
"http://xarray.pydata.org/en/stable/.\n"
152152
"Pandas provides a `.to_xarray()` method to help "
153153
"automate this conversion.\n",
154-
DeprecationWarning, stacklevel=3)
154+
FutureWarning, stacklevel=3)
155155

156156
self._init_data(data=data, items=items, major_axis=major_axis,
157157
minor_axis=minor_axis, copy=copy, dtype=dtype)

pandas/tests/generic/test_label_or_level_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def df_duplabels(df):
4646

4747
@pytest.fixture
4848
def panel():
49-
with tm.assert_produces_warning(DeprecationWarning,
49+
with tm.assert_produces_warning(FutureWarning,
5050
check_stacklevel=False):
5151
return pd.Panel()
5252

0 commit comments

Comments
 (0)