Skip to content

Commit 6b1871c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into makbigc-enh-21801-2
2 parents 7bedc4b + 4e185fc commit 6b1871c

File tree

13 files changed

+80
-1607
lines changed

13 files changed

+80
-1607
lines changed

asv_bench/benchmarks/categoricals.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
import numpy as np
42
import pandas as pd
53
import pandas.util.testing as tm
@@ -133,15 +131,10 @@ def setup(self):
133131

134132
self.s_str = pd.Series(tm.makeCategoricalIndex(N, ncats)).astype(str)
135133
self.s_str_cat = self.s_str.astype('category')
136-
with warnings.catch_warnings(record=True):
137-
self.s_str_cat_ordered = self.s_str.astype('category',
138-
ordered=True)
139-
134+
self.s_str_cat_ordered = self.s_str_cat.cat.as_ordered()
140135
self.s_int = pd.Series(np.random.randint(0, ncats, size=N))
141136
self.s_int_cat = self.s_int.astype('category')
142-
with warnings.catch_warnings(record=True):
143-
self.s_int_cat_ordered = self.s_int.astype('category',
144-
ordered=True)
137+
self.s_int_cat_ordered = self.s_int_cat.cat.as_ordered()
145138

146139
def time_rank_string(self):
147140
self.s_str.rank()

doc/source/getting_started/basics.rst

+1
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,7 @@ In this case, provide ``pipe`` with a tuple of ``(callable, data_keyword)``.
784784
For example, we can fit a regression using statsmodels. Their API expects a formula first and a ``DataFrame`` as the second argument, ``data``. We pass in the function, keyword pair ``(sm.ols, 'data')`` to ``pipe``:
785785

786786
.. ipython:: python
787+
:okwarning:
787788
788789
import statsmodels.formula.api as sm
789790

doc/source/whatsnew/v0.11.0.rst

+25-9
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,31 @@ Enhancements
377377
378378
- ``Squeeze`` to possibly remove length 1 dimensions from an object.
379379

380-
.. ipython:: python
381-
:okwarning:
382-
383-
p = pd.Panel(np.random.randn(3, 4, 4), items=['ItemA', 'ItemB', 'ItemC'],
384-
major_axis=pd.date_range('20010102', periods=4),
385-
minor_axis=['A', 'B', 'C', 'D'])
386-
p
387-
p.reindex(items=['ItemA']).squeeze()
388-
p.reindex(items=['ItemA'], minor=['B']).squeeze()
380+
.. code-block:: python
381+
382+
>>> p = pd.Panel(np.random.randn(3, 4, 4), items=['ItemA', 'ItemB', 'ItemC'],
383+
... major_axis=pd.date_range('20010102', periods=4),
384+
... minor_axis=['A', 'B', 'C', 'D'])
385+
>>> p
386+
<class 'pandas.core.panel.Panel'>
387+
Dimensions: 3 (items) x 4 (major_axis) x 4 (minor_axis)
388+
Items axis: ItemA to ItemC
389+
Major_axis axis: 2001-01-02 00:00:00 to 2001-01-05 00:00:00
390+
Minor_axis axis: A to D
391+
392+
>>> p.reindex(items=['ItemA']).squeeze()
393+
A B C D
394+
2001-01-02 0.926089 -2.026458 0.501277 -0.204683
395+
2001-01-03 -0.076524 1.081161 1.141361 0.479243
396+
2001-01-04 0.641817 -0.185352 1.824568 0.809152
397+
2001-01-05 0.575237 0.669934 1.398014 -0.399338
398+
399+
>>> p.reindex(items=['ItemA'], minor=['B']).squeeze()
400+
2001-01-02 -2.026458
401+
2001-01-03 1.081161
402+
2001-01-04 -0.185352
403+
2001-01-05 0.669934
404+
Freq: D, Name: B, dtype: float64
389405
390406
- In ``pd.io.data.Options``,
391407

doc/source/whatsnew/v0.15.0.rst

+12-7
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,19 @@ Other notable API changes:
701701
702702
This can also be seen in multi-axis indexing with a ``Panel``.
703703

704-
.. ipython:: python
705-
:okwarning:
704+
.. code-block:: python
705+
706+
>>> p = pd.Panel(np.arange(2 * 3 * 4).reshape(2, 3, 4),
707+
... items=['ItemA', 'ItemB'],
708+
... major_axis=[1, 2, 3],
709+
... minor_axis=['A', 'B', 'C', 'D'])
710+
>>> p
711+
<class 'pandas.core.panel.Panel'>
712+
Dimensions: 2 (items) x 3 (major_axis) x 4 (minor_axis)
713+
Items axis: ItemA to ItemB
714+
Major_axis axis: 1 to 3
715+
Minor_axis axis: A to D
706716
707-
p = pd.Panel(np.arange(2 * 3 * 4).reshape(2, 3, 4),
708-
items=['ItemA', 'ItemB'],
709-
major_axis=[1, 2, 3],
710-
minor_axis=['A', 'B', 'C', 'D'])
711-
p
712717
713718
The following would raise ``KeyError`` prior to 0.15.0:
714719

doc/source/whatsnew/v0.15.2.rst

+9-4
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,16 @@ Other enhancements:
160160
161161
- ``Panel`` now supports the ``all`` and ``any`` aggregation functions. (:issue:`8302`):
162162

163-
.. ipython:: python
164-
:okwarning:
163+
.. code-block:: python
165164
166-
p = pd.Panel(np.random.rand(2, 5, 4) > 0.1)
167-
p.all()
165+
>>> p = pd.Panel(np.random.rand(2, 5, 4) > 0.1)
166+
>>> p.all()
167+
0 1 2 3
168+
0 True True True True
169+
1 True False True True
170+
2 True True True True
171+
3 False True False True
172+
4 True True True True
168173
169174
- Added support for ``utcfromtimestamp()``, ``fromtimestamp()``, and ``combine()`` on `Timestamp` class (:issue:`5351`).
170175
- 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>`__.

pandas/__init__.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565

6666
# misc
6767
np, Grouper, factorize, unique, value_counts, NamedAgg,
68-
array, Categorical, set_eng_float_format, Series, DataFrame,
69-
Panel)
68+
array, Categorical, set_eng_float_format, Series, DataFrame)
7069

7170
from pandas.core.sparse.api import (
7271
SparseArray, SparseDataFrame, SparseSeries, SparseDtype)
@@ -118,6 +117,30 @@
118117
__git_version__ = v.get('full-revisionid')
119118
del get_versions, v
120119

120+
121+
# GH 27101
122+
# TODO: remove Panel compat in 1.0
123+
if pandas.compat.PY37:
124+
def __getattr__(name):
125+
if name == 'Panel':
126+
import warnings
127+
warnings.warn(
128+
"The Panel class is removed from pandas. Accessing it "
129+
"from the top-level namespace will also be removed in "
130+
"the next version",
131+
FutureWarning, stacklevel=2)
132+
133+
class Panel:
134+
pass
135+
136+
return Panel
137+
raise AttributeError(
138+
"module 'pandas' has no attribute '{}'".format(name))
139+
else:
140+
class Panel:
141+
pass
142+
143+
121144
# module level doc-string
122145
__doc__ = """
123146
pandas - a powerful data analysis and manipulation library for Python

pandas/core/api.py

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
from pandas.core.series import Series
3737
from pandas.core.frame import DataFrame
38-
from pandas.core.panel import Panel
3938

4039
# TODO: Remove import when statsmodels updates #18264
4140
from pandas.core.reshape.reshape import get_dummies

pandas/core/dtypes/generic.py

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def _check(cls, inst):
4545
ABCDataFrame = create_pandas_abc_type("ABCDataFrame", "_typ", ("dataframe", ))
4646
ABCSparseDataFrame = create_pandas_abc_type("ABCSparseDataFrame", "_subtyp",
4747
("sparse_frame", ))
48-
ABCPanel = create_pandas_abc_type("ABCPanel", "_typ", ("panel",))
4948
ABCSparseSeries = create_pandas_abc_type("ABCSparseSeries", "_subtyp",
5049
('sparse_series',
5150
'sparse_time_series'))

pandas/core/internals/concat.py

-2
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,6 @@ def is_uniform_join_units(join_units):
376376
all(not ju.is_na or ju.block.is_extension for ju in join_units) and
377377
# no blocks with indexers (as then the dimensions do not fit)
378378
all(not ju.indexers for ju in join_units) and
379-
# disregard Panels
380-
all(ju.block.ndim <= 2 for ju in join_units) and
381379
# only use this path when there is something to concatenate
382380
len(join_units) > 1)
383381

pandas/core/internals/managers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
class BlockManager(PandasObject):
4444
"""
45-
Core internal data structure to implement DataFrame, Series, Panel, etc.
45+
Core internal data structure to implement DataFrame, Series, etc.
4646
4747
Manage a bunch of labeled 2D mixed-type ndarrays. Essentially it's a
4848
lightweight blocked set of labeled data to be manipulated by the DataFrame

0 commit comments

Comments
 (0)