Skip to content

CLN/DEPR: Final panel removal #27101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 3, 2019
34 changes: 25 additions & 9 deletions doc/source/whatsnew/v0.11.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,31 @@ Enhancements

- ``Squeeze`` to possibly remove length 1 dimensions from an object.

.. ipython:: python
:okwarning:

p = pd.Panel(np.random.randn(3, 4, 4), items=['ItemA', 'ItemB', 'ItemC'],
major_axis=pd.date_range('20010102', periods=4),
minor_axis=['A', 'B', 'C', 'D'])
p
p.reindex(items=['ItemA']).squeeze()
p.reindex(items=['ItemA'], minor=['B']).squeeze()
.. code-block:: python

>>> p = pd.Panel(np.random.randn(3, 4, 4), items=['ItemA', 'ItemB', 'ItemC'],
major_axis=pd.date_range('20010102', periods=4),
minor_axis=['A', 'B', 'C', 'D'])
>>> p
<class 'pandas.core.panel.Panel'>
Dimensions: 3 (items) x 4 (major_axis) x 4 (minor_axis)
Items axis: ItemA to ItemC
Major_axis axis: 2001-01-02 00:00:00 to 2001-01-05 00:00:00
Minor_axis axis: A to D

>>> p.reindex(items=['ItemA']).squeeze()
A B C D
2001-01-02 0.926089 -2.026458 0.501277 -0.204683
2001-01-03 -0.076524 1.081161 1.141361 0.479243
2001-01-04 0.641817 -0.185352 1.824568 0.809152
2001-01-05 0.575237 0.669934 1.398014 -0.399338

>>> p.reindex(items=['ItemA'], minor=['B']).squeeze()
2001-01-02 -2.026458
2001-01-03 1.081161
2001-01-04 -0.185352
2001-01-05 0.669934
Freq: D, Name: B, dtype: float64

- In ``pd.io.data.Options``,

Expand Down
19 changes: 12 additions & 7 deletions doc/source/whatsnew/v0.15.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -701,14 +701,19 @@ Other notable API changes:

This can also be seen in multi-axis indexing with a ``Panel``.

.. ipython:: python
:okwarning:
.. code-block:: python

>>> p = pd.Panel(np.arange(2 * 3 * 4).reshape(2, 3, 4),
items=['ItemA', 'ItemB'],
major_axis=[1, 2, 3],
minor_axis=['A', 'B', 'C', 'D'])
>>> p
<class 'pandas.core.panel.Panel'>
Dimensions: 2 (items) x 3 (major_axis) x 4 (minor_axis)
Items axis: ItemA to ItemB
Major_axis axis: 1 to 3
Minor_axis axis: A to D

p = pd.Panel(np.arange(2 * 3 * 4).reshape(2, 3, 4),
items=['ItemA', 'ItemB'],
major_axis=[1, 2, 3],
minor_axis=['A', 'B', 'C', 'D'])
p

The following would raise ``KeyError`` prior to 0.15.0:

Expand Down
13 changes: 9 additions & 4 deletions doc/source/whatsnew/v0.15.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,16 @@ Other enhancements:

- ``Panel`` now supports the ``all`` and ``any`` aggregation functions. (:issue:`8302`):

.. ipython:: python
:okwarning:
.. code-block:: python

p = pd.Panel(np.random.rand(2, 5, 4) > 0.1)
p.all()
>>> p = pd.Panel(np.random.rand(2, 5, 4) > 0.1)
>>> p.all()
0 1 2 3
0 True True True True
1 True False True True
2 True True True True
3 False True False True
4 True True True True

- Added support for ``utcfromtimestamp()``, ``fromtimestamp()``, and ``combine()`` on `Timestamp` class (:issue:`5351`).
- Added Google Analytics (`pandas.io.ga`) basic documentation (:issue:`8835`). See `here <http://pandas.pydata.org/pandas-docs/version/0.15.2/remote_data.html#remote-data-ga>`__.
Expand Down
23 changes: 21 additions & 2 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@

# misc
np, Grouper, factorize, unique, value_counts, NamedAgg,
array, Categorical, set_eng_float_format, Series, DataFrame,
Panel)
array, Categorical, set_eng_float_format, Series, DataFrame)

from pandas.core.sparse.api import (
SparseArray, SparseDataFrame, SparseSeries, SparseDtype)
Expand Down Expand Up @@ -118,6 +117,26 @@
__git_version__ = v.get('full-revisionid')
del get_versions, v


# GH 27101
# TODO: remove Panel compat in 1.0
if pandas.compat.PY37:
def __getattr__(name):
if name == 'Panel':
import warnings
warnings.warn(
"The Panel class is removed from pandas. Accessing it "
"from the top-level namespace will also be removed in "
"the next version",
FutureWarning, stacklevel=2)
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downstream are expecting this to be a type so they can do isinstance(thing, pd.Panel). Will make another dummy class Panel here (not outside the getattr, so that we don't pollute the namespace on py37+).

raise AttributeError(
"module 'pandas' has no attribute {}".format(name))
else:
class Panel:
pass


# module level doc-string
__doc__ = """
pandas - a powerful data analysis and manipulation library for Python
Expand Down
1 change: 0 additions & 1 deletion pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

from pandas.core.series import Series
from pandas.core.frame import DataFrame
from pandas.core.panel import Panel

# TODO: Remove import when statsmodels updates #18264
from pandas.core.reshape.reshape import get_dummies
Expand Down
1 change: 0 additions & 1 deletion pandas/core/dtypes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def _check(cls, inst):
ABCDataFrame = create_pandas_abc_type("ABCDataFrame", "_typ", ("dataframe", ))
ABCSparseDataFrame = create_pandas_abc_type("ABCSparseDataFrame", "_subtyp",
("sparse_frame", ))
ABCPanel = create_pandas_abc_type("ABCPanel", "_typ", ("panel",))
ABCSparseSeries = create_pandas_abc_type("ABCSparseSeries", "_subtyp",
('sparse_series',
'sparse_time_series'))
Expand Down
2 changes: 0 additions & 2 deletions pandas/core/internals/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,6 @@ def is_uniform_join_units(join_units):
all(not ju.is_na or ju.block.is_extension for ju in join_units) and
# no blocks with indexers (as then the dimensions do not fit)
all(not ju.indexers for ju in join_units) and
# disregard Panels
all(ju.block.ndim <= 2 for ju in join_units) and
# only use this path when there is something to concatenate
len(join_units) > 1)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

class BlockManager(PandasObject):
"""
Core internal data structure to implement DataFrame, Series, Panel, etc.
Core internal data structure to implement DataFrame, Series, etc.

Manage a bunch of labeled 2D mixed-type ndarrays. Essentially it's a
lightweight blocked set of labeled data to be manipulated by the DataFrame
Expand Down
Loading