Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into makbigc-enh-21801-2
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Jul 3, 2019
2 parents 7bedc4b + 4e185fc commit 6b1871c
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 1,607 deletions.
11 changes: 2 additions & 9 deletions asv_bench/benchmarks/categoricals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

import numpy as np
import pandas as pd
import pandas.util.testing as tm
Expand Down Expand Up @@ -133,15 +131,10 @@ def setup(self):

self.s_str = pd.Series(tm.makeCategoricalIndex(N, ncats)).astype(str)
self.s_str_cat = self.s_str.astype('category')
with warnings.catch_warnings(record=True):
self.s_str_cat_ordered = self.s_str.astype('category',
ordered=True)

self.s_str_cat_ordered = self.s_str_cat.cat.as_ordered()
self.s_int = pd.Series(np.random.randint(0, ncats, size=N))
self.s_int_cat = self.s_int.astype('category')
with warnings.catch_warnings(record=True):
self.s_int_cat_ordered = self.s_int.astype('category',
ordered=True)
self.s_int_cat_ordered = self.s_int_cat.cat.as_ordered()

def time_rank_string(self):
self.s_str.rank()
Expand Down
1 change: 1 addition & 0 deletions doc/source/getting_started/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ In this case, provide ``pipe`` with a tuple of ``(callable, data_keyword)``.
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``:

.. ipython:: python
:okwarning:
import statsmodels.formula.api as sm
Expand Down
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
27 changes: 25 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,30 @@
__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)

class Panel:
pass

return Panel
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

0 comments on commit 6b1871c

Please sign in to comment.