Skip to content

Commit df771cc

Browse files
ArtificialQualiajreback
authored andcommitted
DOC: Remove makePanel from docs (#25609) (#25612)
1 parent e28ae70 commit df771cc

File tree

4 files changed

+220
-97
lines changed

4 files changed

+220
-97
lines changed

doc/source/getting_started/dsintro.rst

-44
Original file line numberDiff line numberDiff line change
@@ -1030,47 +1030,3 @@ method:
10301030
major_axis=pd.date_range('1/1/2000', periods=5),
10311031
minor_axis=['a', 'b', 'c', 'd'])
10321032
panel.to_frame()
1033-
1034-
1035-
.. _dsintro.deprecate_panel:
1036-
1037-
Deprecate Panel
1038-
---------------
1039-
1040-
Over the last few years, pandas has increased in both breadth and depth, with new features,
1041-
datatype support, and manipulation routines. As a result, supporting efficient indexing and functional
1042-
routines for ``Series``, ``DataFrame`` and ``Panel`` has contributed to an increasingly fragmented and
1043-
difficult-to-understand code base.
1044-
1045-
The 3-D structure of a ``Panel`` is much less common for many types of data analysis,
1046-
than the 1-D of the ``Series`` or the 2-D of the ``DataFrame``. Going forward it makes sense for
1047-
pandas to focus on these areas exclusively.
1048-
1049-
Oftentimes, one can simply use a MultiIndex ``DataFrame`` for easily working with higher dimensional data.
1050-
1051-
In addition, the ``xarray`` package was built from the ground up, specifically in order to
1052-
support the multi-dimensional analysis that is one of ``Panel`` s main use cases.
1053-
`Here is a link to the xarray panel-transition documentation <https://xarray.pydata.org/en/stable/pandas.html#panel-transition>`__.
1054-
1055-
.. ipython:: python
1056-
:okwarning:
1057-
1058-
import pandas.util.testing as tm
1059-
p = tm.makePanel()
1060-
p
1061-
1062-
Convert to a MultiIndex DataFrame.
1063-
1064-
.. ipython:: python
1065-
:okwarning:
1066-
1067-
p.to_frame()
1068-
1069-
Alternatively, one can convert to an xarray ``DataArray``.
1070-
1071-
.. ipython:: python
1072-
:okwarning:
1073-
1074-
p.to_xarray()
1075-
1076-
You can see the full-documentation for the `xarray package <https://xarray.pydata.org/en/stable/>`__.

doc/source/whatsnew/v0.13.1.rst

+122-27
Original file line numberDiff line numberDiff line change
@@ -222,60 +222,155 @@ Enhancements
222222
223223
- Panel :meth:`~pandas.Panel.apply` will work on non-ufuncs. See :ref:`the docs<basics.apply>`.
224224

225-
.. ipython:: python
225+
.. code-block:: ipython
226+
227+
In [28]: import pandas.util.testing as tm
228+
229+
In [29]: panel = tm.makePanel(5)
226230
227-
import pandas.util.testing as tm
228-
panel = tm.makePanel(5)
229-
panel
230-
panel['ItemA']
231+
In [30]: panel
232+
Out[30]:
233+
<class 'pandas.core.panel.Panel'>
234+
Dimensions: 3 (items) x 5 (major_axis) x 4 (minor_axis)
235+
Items axis: ItemA to ItemC
236+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
237+
Minor_axis axis: A to D
238+
239+
In [31]: panel['ItemA']
240+
Out[31]:
241+
A B C D
242+
2000-01-03 -0.673690 0.577046 -1.344312 -1.469388
243+
2000-01-04 0.113648 -1.715002 0.844885 0.357021
244+
2000-01-05 -1.478427 -1.039268 1.075770 -0.674600
245+
2000-01-06 0.524988 -0.370647 -0.109050 -1.776904
246+
2000-01-07 0.404705 -1.157892 1.643563 -0.968914
247+
248+
[5 rows x 4 columns]
231249
232250
Specifying an ``apply`` that operates on a Series (to return a single element)
233251

234-
.. ipython:: python
252+
.. code-block:: ipython
253+
254+
In [32]: panel.apply(lambda x: x.dtype, axis='items')
255+
Out[32]:
256+
A B C D
257+
2000-01-03 float64 float64 float64 float64
258+
2000-01-04 float64 float64 float64 float64
259+
2000-01-05 float64 float64 float64 float64
260+
2000-01-06 float64 float64 float64 float64
261+
2000-01-07 float64 float64 float64 float64
235262
236-
panel.apply(lambda x: x.dtype, axis='items')
263+
[5 rows x 4 columns]
237264
238265
A similar reduction type operation
239266

240-
.. ipython:: python
267+
.. code-block:: ipython
268+
269+
In [33]: panel.apply(lambda x: x.sum(), axis='major_axis')
270+
Out[33]:
271+
ItemA ItemB ItemC
272+
A -1.108775 -1.090118 -2.984435
273+
B -3.705764 0.409204 1.866240
274+
C 2.110856 2.960500 -0.974967
275+
D -4.532785 0.303202 -3.685193
241276
242-
panel.apply(lambda x: x.sum(), axis='major_axis')
277+
[4 rows x 3 columns]
243278
244279
This is equivalent to
245280

246-
.. ipython:: python
281+
.. code-block:: ipython
282+
283+
In [34]: panel.sum('major_axis')
284+
Out[34]:
285+
ItemA ItemB ItemC
286+
A -1.108775 -1.090118 -2.984435
287+
B -3.705764 0.409204 1.866240
288+
C 2.110856 2.960500 -0.974967
289+
D -4.532785 0.303202 -3.685193
247290
248-
panel.sum('major_axis')
291+
[4 rows x 3 columns]
249292
250293
A transformation operation that returns a Panel, but is computing
251294
the z-score across the major_axis
252295

253-
.. ipython:: python
296+
.. code-block:: ipython
254297
255-
result = panel.apply(lambda x: (x - x.mean()) / x.std(),
256-
axis='major_axis')
257-
result
258-
result['ItemA']
298+
In [35]: result = panel.apply(lambda x: (x - x.mean()) / x.std(),
299+
....: axis='major_axis')
300+
....:
301+
302+
In [36]: result
303+
Out[36]:
304+
<class 'pandas.core.panel.Panel'>
305+
Dimensions: 3 (items) x 5 (major_axis) x 4 (minor_axis)
306+
Items axis: ItemA to ItemC
307+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
308+
Minor_axis axis: A to D
309+
310+
In [37]: result['ItemA'] # noqa E999
311+
Out[37]:
312+
A B C D
313+
2000-01-03 -0.535778 1.500802 -1.506416 -0.681456
314+
2000-01-04 0.397628 -1.108752 0.360481 1.529895
315+
2000-01-05 -1.489811 -0.339412 0.557374 0.280845
316+
2000-01-06 0.885279 0.421830 -0.453013 -1.053785
317+
2000-01-07 0.742682 -0.474468 1.041575 -0.075499
318+
319+
[5 rows x 4 columns]
259320
260321
- Panel :meth:`~pandas.Panel.apply` operating on cross-sectional slabs. (:issue:`1148`)
261322

262-
.. ipython:: python
323+
.. code-block:: ipython
263324
264-
def f(x):
265-
return ((x.T - x.mean(1)) / x.std(1)).T
325+
In [38]: def f(x):
326+
....: return ((x.T - x.mean(1)) / x.std(1)).T
327+
....:
266328
267-
result = panel.apply(f, axis=['items', 'major_axis'])
268-
result
269-
result.loc[:, :, 'ItemA']
329+
In [39]: result = panel.apply(f, axis=['items', 'major_axis'])
270330
271-
This is equivalent to the following
331+
In [40]: result
332+
Out[40]:
333+
<class 'pandas.core.panel.Panel'>
334+
Dimensions: 4 (items) x 5 (major_axis) x 3 (minor_axis)
335+
Items axis: A to D
336+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
337+
Minor_axis axis: ItemA to ItemC
272338
273-
.. ipython:: python
339+
In [41]: result.loc[:, :, 'ItemA']
340+
Out[41]:
341+
A B C D
342+
2000-01-03 0.012922 -0.030874 -0.629546 -0.757034
343+
2000-01-04 0.392053 -1.071665 0.163228 0.548188
344+
2000-01-05 -1.093650 -0.640898 0.385734 -1.154310
345+
2000-01-06 1.005446 -1.154593 -0.595615 -0.809185
346+
2000-01-07 0.783051 -0.198053 0.919339 -1.052721
347+
348+
[5 rows x 4 columns]
274349
275-
result = pd.Panel({ax: f(panel.loc[:, :, ax]) for ax in panel.minor_axis})
350+
This is equivalent to the following
351+
352+
.. code-block:: ipython
276353
277-
result
278-
result.loc[:, :, 'ItemA']
354+
In [42]: result = pd.Panel({ax: f(panel.loc[:, :, ax]) for ax in panel.minor_axis})
355+
356+
In [43]: result
357+
Out[43]:
358+
<class 'pandas.core.panel.Panel'>
359+
Dimensions: 4 (items) x 5 (major_axis) x 3 (minor_axis)
360+
Items axis: A to D
361+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-07 00:00:00
362+
Minor_axis axis: ItemA to ItemC
363+
364+
In [44]: result.loc[:, :, 'ItemA']
365+
Out[44]:
366+
A B C D
367+
2000-01-03 0.012922 -0.030874 -0.629546 -0.757034
368+
2000-01-04 0.392053 -1.071665 0.163228 0.548188
369+
2000-01-05 -1.093650 -0.640898 0.385734 -1.154310
370+
2000-01-06 1.005446 -1.154593 -0.595615 -0.809185
371+
2000-01-07 0.783051 -0.198053 0.919339 -1.052721
372+
373+
[5 rows x 4 columns]
279374
280375
Performance
281376
~~~~~~~~~~~

doc/source/whatsnew/v0.20.0.rst

+50-14
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ Check the :ref:`API Changes <whatsnew_0200.api_breaking>` and :ref:`deprecations
4545
New features
4646
~~~~~~~~~~~~
4747

48-
.. ipython:: python
49-
:suppress:
50-
51-
import pandas.util.testing as tm
52-
5348
.. _whatsnew_0200.enhancements.agg:
5449

5550
``agg`` API for DataFrame/Series
@@ -1363,24 +1358,65 @@ Deprecate Panel
13631358
with a ``MultiIndex`` on a ``DataFrame`` via the :meth:`~Panel.to_frame` or with the `xarray package <http://xarray.pydata.org/en/stable/>`__. Pandas
13641359
provides a :meth:`~Panel.to_xarray` method to automate this conversion. For more details see :ref:`Deprecate Panel <dsintro.deprecate_panel>` documentation. (:issue:`13563`).
13651360

1366-
.. ipython:: python
1367-
:okwarning:
1361+
.. code-block:: ipython
13681362
1369-
p = tm.makePanel()
1370-
p
1363+
In [133]: import pandas.util.testing as tm
1364+
1365+
In [134]: p = tm.makePanel()
1366+
1367+
In [135]: p
1368+
Out[135]:
1369+
<class 'pandas.core.panel.Panel'>
1370+
Dimensions: 3 (items) x 3 (major_axis) x 4 (minor_axis)
1371+
Items axis: ItemA to ItemC
1372+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-05 00:00:00
1373+
Minor_axis axis: A to D
13711374
13721375
Convert to a MultiIndex DataFrame
13731376

1374-
.. ipython:: python
1377+
.. code-block:: ipython
13751378
1376-
p.to_frame()
1379+
In [136]: p.to_frame()
1380+
Out[136]:
1381+
ItemA ItemB ItemC
1382+
major minor
1383+
2000-01-03 A 0.628776 -1.409432 0.209395
1384+
B 0.988138 -1.347533 -0.896581
1385+
C -0.938153 1.272395 -0.161137
1386+
D -0.223019 -0.591863 -1.051539
1387+
2000-01-04 A 0.186494 1.422986 -0.592886
1388+
B -0.072608 0.363565 1.104352
1389+
C -1.239072 -1.449567 0.889157
1390+
D 2.123692 -0.414505 -0.319561
1391+
2000-01-05 A 0.952478 -2.147855 -1.473116
1392+
B -0.550603 -0.014752 -0.431550
1393+
C 0.139683 -1.195524 0.288377
1394+
D 0.122273 -1.425795 -0.619993
1395+
1396+
[12 rows x 3 columns]
13771397
13781398
Convert to an xarray DataArray
13791399

1380-
.. ipython:: python
1381-
:okwarning:
1400+
.. code-block:: ipython
13821401
1383-
p.to_xarray()
1402+
In [137]: p.to_xarray()
1403+
Out[137]:
1404+
<xarray.DataArray (items: 3, major_axis: 3, minor_axis: 4)>
1405+
array([[[ 0.628776, 0.988138, -0.938153, -0.223019],
1406+
[ 0.186494, -0.072608, -1.239072, 2.123692],
1407+
[ 0.952478, -0.550603, 0.139683, 0.122273]],
1408+
1409+
[[-1.409432, -1.347533, 1.272395, -0.591863],
1410+
[ 1.422986, 0.363565, -1.449567, -0.414505],
1411+
[-2.147855, -0.014752, -1.195524, -1.425795]],
1412+
1413+
[[ 0.209395, -0.896581, -0.161137, -1.051539],
1414+
[-0.592886, 1.104352, 0.889157, -0.319561],
1415+
[-1.473116, -0.43155 , 0.288377, -0.619993]]])
1416+
Coordinates:
1417+
* items (items) object 'ItemA' 'ItemB' 'ItemC'
1418+
* major_axis (major_axis) datetime64[ns] 2000-01-03 2000-01-04 2000-01-05
1419+
* minor_axis (minor_axis) object 'A' 'B' 'C' 'D'
13841420
13851421
.. _whatsnew_0200.api_breaking.deprecate_group_agg_dict:
13861422

doc/source/whatsnew/v0.23.0.rst

+48-12
Original file line numberDiff line numberDiff line change
@@ -646,29 +646,65 @@ Deprecate Panel
646646
with a ``MultiIndex`` on a ``DataFrame`` via the :meth:`~Panel.to_frame` or with the `xarray package <http://xarray.pydata.org/en/stable/>`__. Pandas
647647
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`).
648648

649-
.. ipython:: python
650-
:suppress:
649+
.. code-block:: ipython
651650
652-
import pandas.util.testing as tm
651+
In [75]: import pandas.util.testing as tm
653652
654-
.. ipython:: python
655-
:okwarning:
653+
In [76]: p = tm.makePanel()
656654
657-
p = tm.makePanel()
658-
p
655+
In [77]: p
656+
Out[77]:
657+
<class 'pandas.core.panel.Panel'>
658+
Dimensions: 3 (items) x 3 (major_axis) x 4 (minor_axis)
659+
Items axis: ItemA to ItemC
660+
Major_axis axis: 2000-01-03 00:00:00 to 2000-01-05 00:00:00
661+
Minor_axis axis: A to D
659662
660663
Convert to a MultiIndex DataFrame
661664

662-
.. ipython:: python
665+
.. code-block:: ipython
663666
664-
p.to_frame()
667+
In [78]: p.to_frame()
668+
Out[78]:
669+
ItemA ItemB ItemC
670+
major minor
671+
2000-01-03 A 0.469112 0.721555 0.404705
672+
B -1.135632 0.271860 -1.039268
673+
C 0.119209 0.276232 -1.344312
674+
D -2.104569 0.113648 -0.109050
675+
2000-01-04 A -0.282863 -0.706771 0.577046
676+
B 1.212112 -0.424972 -0.370647
677+
C -1.044236 -1.087401 0.844885
678+
D -0.494929 -1.478427 1.643563
679+
2000-01-05 A -1.509059 -1.039575 -1.715002
680+
B -0.173215 0.567020 -1.157892
681+
C -0.861849 -0.673690 1.075770
682+
D 1.071804 0.524988 -1.469388
683+
684+
[12 rows x 3 columns]
665685
666686
Convert to an xarray DataArray
667687

668-
.. ipython:: python
669-
:okwarning:
688+
.. code-block:: ipython
670689
671-
p.to_xarray()
690+
In [79]: p.to_xarray()
691+
Out[79]:
692+
<xarray.DataArray (items: 3, major_axis: 3, minor_axis: 4)>
693+
array([[[ 0.469112, -1.135632, 0.119209, -2.104569],
694+
[-0.282863, 1.212112, -1.044236, -0.494929],
695+
[-1.509059, -0.173215, -0.861849, 1.071804]],
696+
697+
[[ 0.721555, 0.27186 , 0.276232, 0.113648],
698+
[-0.706771, -0.424972, -1.087401, -1.478427],
699+
[-1.039575, 0.56702 , -0.67369 , 0.524988]],
700+
701+
[[ 0.404705, -1.039268, -1.344312, -0.10905 ],
702+
[ 0.577046, -0.370647, 0.844885, 1.643563],
703+
[-1.715002, -1.157892, 1.07577 , -1.469388]]])
704+
Coordinates:
705+
* items (items) object 'ItemA' 'ItemB' 'ItemC'
706+
* major_axis (major_axis) datetime64[ns] 2000-01-03 2000-01-04 2000-01-05
707+
* minor_axis (minor_axis) object 'A' 'B' 'C' 'D'
672708
673709
674710
.. _whatsnew_0230.api_breaking.core_common:

0 commit comments

Comments
 (0)