Skip to content

Commit d04db2e

Browse files
committed
add deprecate_panel section to docs
1 parent 538b8e8 commit d04db2e

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

doc/source/dsintro.rst

+41-4
Original file line numberDiff line numberDiff line change
@@ -766,10 +766,7 @@ Panel
766766
.. warning::
767767

768768
In 0.20.0, ``Panel`` is deprecated and will be removed in
769-
a future version. The recommended way to represent 3-D data are
770-
with a ``MultiIndex``on a ``DataFrame`` via the :meth:`~Panel.to_frame` or
771-
with the `xarray package <http://xarray.pydata.org/en/stable/>`__. Pandas
772-
provides a :meth:`~Panel.to_xarray` method to automate this conversion.
769+
a future version. See the section :ref:`Deprecate Panel <dsintro.deprecate_panel>`.
773770

774771
Panel is a somewhat less-used, but still important container for 3-dimensional
775772
data. The term `panel data <http://en.wikipedia.org/wiki/Panel_data>`__ is
@@ -937,6 +934,46 @@ method:
937934
minor_axis=['a', 'b', 'c', 'd'])
938935
panel.to_frame()
939936
937+
938+
.. _dsintro.deprecate_panel:
939+
940+
Deprecate Panel
941+
---------------
942+
943+
Over the last few years, pandas has increased in both breadth and depth, with new features,
944+
datatype support, and manipulation routines. As a result, supporting efficient indexing and functional
945+
routines for ``Series``, ``DataFrame`` and ``Panel`` has contributed to an increasingly fragmented and
946+
difficult-to-understand codebase.
947+
948+
The 3-d structure of a ``Panel`` is much less common for many types of data analysis,
949+
than the 1-d of the ``Series`` or the 2-D of the ``DataFrame``. Going forward it makes sense for
950+
pandas to focus on these areas exclusively.
951+
952+
Oftentimes, one can simply use a MultiIndex ``DataFrame`` for easily working with higher dimensional data.
953+
954+
In additon, the ``xarray`` package was built from the ground up, specifically in order to
955+
support the multi-dimensional analysis that is one of ``Panel`` s main usecases.
956+
957+
.. ipython:: python
958+
:okwarning:
959+
960+
p = tm.makePanel()
961+
p
962+
963+
Convert to a MultiIndex DataFrame
964+
965+
.. ipython:: python
966+
967+
p.to_frame()
968+
969+
Alternatively, one can convert to an xarray ``DataArray``.
970+
971+
.. ipython:: python
972+
973+
p.to_xarray()
974+
975+
You can see the full-documentation for the `xarray package <http://xarray.pydata.org/en/stable/>`__.
976+
940977
.. _dsintro.panelnd:
941978
.. _dsintro.panel4d:
942979

doc/source/whatsnew/v0.20.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ Deprecate Panel
435435

436436
``Panel`` is deprecated and will be removed in a future version. The recommended way to represent 3-D data are
437437
with a ``MultiIndex``on a ``DataFrame`` via the :meth:`~Panel.to_frame` or with the `xarray package <http://xarray.pydata.org/en/stable/>`__. Pandas
438-
provides a :meth:`~Panel.to_xarray` method to automate this conversion (:issue:`13563`).
438+
provides a :meth:`~Panel.to_xarray` method to automate this conversion. See the documentation :ref:`Deprecate Panel <dsintro.deprecate_panel>`. (:issue:`13563`).
439439

440440
.. ipython:: python
441441
:okwarning:
@@ -447,7 +447,7 @@ Convert to a MultiIndex DataFrame
447447

448448
.. ipython:: python
449449

450-
p.frame()
450+
p.to_frame()
451451

452452
Convert to an xarray DataArray
453453

pandas/core/panel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ def __init__(self, data=None, items=None, major_axis=None, minor_axis=None,
136136
"these types of 3-dimensional data are with a "
137137
"MultiIndex on a DataFrame, via the "
138138
"Panel.to_frame() method\n"
139-
"alternatively, you can use the `xarray package "
140-
"<http://xarray.pydata.org/en/stable/>`__.\n"
139+
"Alternatively, you can use the xarray package "
140+
"http://xarray.pydata.org/en/stable/.\n"
141141
"Pandas provides a `.to_xarray()` method to help "
142142
"automate this conversion.\n",
143143
DeprecationWarning, stacklevel=3)

0 commit comments

Comments
 (0)