diff --git a/doc/source/conf.py b/doc/source/conf.py index c59d28a6dc3ea..8693a97bc00f1 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -16,7 +16,6 @@ import inspect import importlib import logging -import warnings import jinja2 from sphinx.ext.autosummary import _import_by_name from numpydoc.docscrape import NumpyDocString @@ -412,12 +411,6 @@ 'wiki ')} -# ignore all deprecation warnings from Panel during doc build -# (to avoid the need to add :okwarning: in many places) -warnings.filterwarnings("ignore", message="\nPanel is deprecated", - category=FutureWarning) - - ipython_warning_is_error = False ipython_exec_lines = [ 'import numpy as np', diff --git a/doc/source/development/extending.rst b/doc/source/development/extending.rst index 9e5034f6d3db0..0bc54f99482ca 100644 --- a/doc/source/development/extending.rst +++ b/doc/source/development/extending.rst @@ -271,7 +271,7 @@ There are 3 constructor properties to be defined: * ``_constructor``: Used when a manipulation result has the same dimensions as the original. * ``_constructor_sliced``: Used when a manipulation result has one lower dimension(s) as the original, such as ``DataFrame`` single columns slicing. -* ``_constructor_expanddim``: Used when a manipulation result has one higher dimension as the original, such as ``Series.to_frame()`` and ``DataFrame.to_panel()``. +* ``_constructor_expanddim``: Used when a manipulation result has one higher dimension as the original, such as ``Series.to_frame()``. Following table shows how ``pandas`` data structures define constructor properties by default. @@ -280,7 +280,7 @@ Property Attributes ``Series`` ``DataFrame`` =========================== ======================= ============= ``_constructor`` ``Series`` ``DataFrame`` ``_constructor_sliced`` ``NotImplementedError`` ``Series`` -``_constructor_expanddim`` ``DataFrame`` ``Panel`` +``_constructor_expanddim`` ``DataFrame`` ``NotImplementedError`` =========================== ======================= ============= Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame`` overriding constructor properties. diff --git a/doc/source/ecosystem.rst b/doc/source/ecosystem.rst index 833308ec9fcc6..f30052be91d40 100644 --- a/doc/source/ecosystem.rst +++ b/doc/source/ecosystem.rst @@ -217,7 +217,7 @@ Pandas DataFrames with timeseries indexes. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PyDatastream is a Python interface to the `Thomson Dataworks Enterprise (DWE/Datastream) `__ -SOAP API to return indexed Pandas DataFrames or Panels with financial data. +SOAP API to return indexed Pandas DataFrames with financial data. This package requires valid credentials for this API (non free). `pandaSDMX `__ diff --git a/doc/source/getting_started/10min.rst b/doc/source/getting_started/10min.rst index 50c53a56174c8..fdf1f05b8e61f 100644 --- a/doc/source/getting_started/10min.rst +++ b/doc/source/getting_started/10min.rst @@ -449,8 +449,8 @@ Merge Concat ~~~~~~ -pandas provides various facilities for easily combining together Series, -DataFrame, and Panel objects with various kinds of set logic for the indexes +pandas provides various facilities for easily combining together Series and +DataFrame objects with various kinds of set logic for the indexes and relational algebra functionality in the case of join / merge-type operations. diff --git a/doc/source/getting_started/basics.rst b/doc/source/getting_started/basics.rst index bbec7b5de1d2e..80e334054a986 100644 --- a/doc/source/getting_started/basics.rst +++ b/doc/source/getting_started/basics.rst @@ -16,9 +16,6 @@ the previous section: s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e']) df = pd.DataFrame(np.random.randn(8, 3), index=index, columns=['A', 'B', 'C']) - wp = pd.Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'], - major_axis=pd.date_range('1/1/2000', periods=5), - minor_axis=['A', 'B', 'C', 'D']) .. _basics.head_tail: @@ -46,7 +43,6 @@ pandas objects have a number of attributes enabling you to access the metadata * Axis labels * **Series**: *index* (only axis) * **DataFrame**: *index* (rows) and *columns* - * **Panel**: *items*, *major_axis*, and *minor_axis* Note, **these attributes can be safely assigned to**! @@ -118,7 +114,7 @@ columns, :meth:`DataFrame.to_numpy` will return the underlying data: df.to_numpy() -If a DataFrame or Panel contains homogeneously-typed data, the ndarray can +If a DataFrame contains homogeneously-typed data, the ndarray can actually be modified in-place, and the changes will be reflected in the data structure. For heterogeneous data (e.g. some of the DataFrame's columns are not all the same dtype), this will not be the case. The values attribute itself, @@ -239,26 +235,6 @@ Furthermore you can align a level of a MultiIndexed DataFrame with a Series. names=['first', 'second']) dfmi.sub(column, axis=0, level='second') -With Panel, describing the matching behavior is a bit more difficult, so -the arithmetic methods instead (and perhaps confusingly?) give you the option -to specify the *broadcast axis*. For example, suppose we wished to demean the -data over a particular axis. This can be accomplished by taking the mean over -an axis and broadcasting over the same axis: - -.. ipython:: python - - major_mean = wp.mean(axis='major') - major_mean - wp.sub(major_mean, axis='major') - -And similarly for ``axis="items"`` and ``axis="minor"``. - -.. note:: - - I could be convinced to make the **axis** argument in the DataFrame methods - match the broadcasting behavior of Panel. Though it would require a - transition period so users can change their code... - Series and Index also support the :func:`divmod` builtin. This function takes the floor division and modulo operation at the same time returning a two-tuple of the same type as the left hand side. For example: @@ -407,7 +383,7 @@ This is because NaNs do not compare as equals: np.nan == np.nan -So, NDFrames (such as Series, DataFrames, and Panels) +So, NDFrames (such as Series and DataFrames) have an :meth:`~DataFrame.equals` method for testing equality, with NaNs in corresponding locations treated as equal. @@ -515,7 +491,7 @@ Descriptive statistics There exists a large number of methods for computing descriptive statistics and other related operations on :ref:`Series `, :ref:`DataFrame -`, and :ref:`Panel `. Most of these +`. Most of these are aggregations (hence producing a lower-dimensional result) like :meth:`~DataFrame.sum`, :meth:`~DataFrame.mean`, and :meth:`~DataFrame.quantile`, but some of them, like :meth:`~DataFrame.cumsum` and :meth:`~DataFrame.cumprod`, @@ -525,8 +501,6 @@ specified by name or integer: * **Series**: no axis argument needed * **DataFrame**: "index" (axis=0, default), "columns" (axis=1) -* **Panel**: "items" (axis=0), "major" (axis=1, default), "minor" - (axis=2) For example: @@ -1481,7 +1455,7 @@ Iteration The behavior of basic iteration over pandas objects depends on the type. When iterating over a Series, it is regarded as array-like, and basic iteration -produces the values. Other data structures, like DataFrame and Panel, +produces the values. Other data structures, like DataFrame, follow the dict-like convention of iterating over the "keys" of the objects. @@ -1489,7 +1463,6 @@ In short, basic iteration (``for i in object``) produces: * **Series**: values * **DataFrame**: column labels -* **Panel**: item labels Thus, for example, iterating over a DataFrame gives you the column names: @@ -1559,13 +1532,12 @@ through key-value pairs: * **Series**: (index, scalar value) pairs * **DataFrame**: (column, Series) pairs -* **Panel**: (item, DataFrame) pairs For example: .. ipython:: python - for item, frame in wp.iteritems(): + for item, frame in df.iteritems(): print(item) print(frame) diff --git a/doc/source/getting_started/dsintro.rst b/doc/source/getting_started/dsintro.rst index 373cffd30ff14..1abca7ac393dd 100644 --- a/doc/source/getting_started/dsintro.rst +++ b/doc/source/getting_started/dsintro.rst @@ -847,186 +847,3 @@ completion mechanism so they can be tab-completed: In [5]: df.fo # noqa: E225, E999 df.foo1 df.foo2 - -.. _basics.panel: - -Panel ------ - -.. warning:: - - In 0.20.0, ``Panel`` is deprecated and will be removed in - a future version. See the section :ref:`Deprecate Panel `. - -Panel is a somewhat less-used, but still important container for 3-dimensional -data. The term `panel data `__ is -derived from econometrics and is partially responsible for the name pandas: -pan(el)-da(ta)-s. The names for the 3 axes are intended to give some semantic -meaning to describing operations involving panel data and, in particular, -econometric analysis of panel data. However, for the strict purposes of slicing -and dicing a collection of DataFrame objects, you may find the axis names -slightly arbitrary: - -* **items**: axis 0, each item corresponds to a DataFrame contained inside -* **major_axis**: axis 1, it is the **index** (rows) of each of the - DataFrames -* **minor_axis**: axis 2, it is the **columns** of each of the DataFrames - -Construction of Panels works about like you would expect: - -From 3D ndarray with optional axis labels -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. ipython:: python - :okwarning: - - wp = pd.Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'], - major_axis=pd.date_range('1/1/2000', periods=5), - minor_axis=['A', 'B', 'C', 'D']) - wp - - -From dict of DataFrame objects -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. ipython:: python - :okwarning: - - data = {'Item1': pd.DataFrame(np.random.randn(4, 3)), - 'Item2': pd.DataFrame(np.random.randn(4, 2))} - pd.Panel(data) - -Note that the values in the dict need only be **convertible to -DataFrame**. Thus, they can be any of the other valid inputs to DataFrame as -per above. - -One helpful factory method is ``Panel.from_dict``, which takes a -dictionary of DataFrames as above, and the following named parameters: - -.. csv-table:: - :header: "Parameter", "Default", "Description" - :widths: 10, 10, 40 - - intersect, ``False``, drops elements whose indices do not align - orient, ``items``, use ``minor`` to use DataFrames' columns as panel items - -For example, compare to the construction above: - -.. ipython:: python - :okwarning: - - pd.Panel.from_dict(data, orient='minor') - -Orient is especially useful for mixed-type DataFrames. If you pass a dict of -DataFrame objects with mixed-type columns, all of the data will get upcasted to -``dtype=object`` unless you pass ``orient='minor'``: - -.. ipython:: python - :okwarning: - - df = pd.DataFrame({'a': ['foo', 'bar', 'baz'], - 'b': np.random.randn(3)}) - df - data = {'item1': df, 'item2': df} - panel = pd.Panel.from_dict(data, orient='minor') - panel['a'] - panel['b'] - panel['b'].dtypes - -.. note:: - - Panel, being less commonly used than Series and DataFrame, - has been slightly neglected feature-wise. A number of methods and options - available in DataFrame are not available in Panel. - -.. _dsintro.to_panel: - -From DataFrame using ``to_panel`` method -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -``to_panel`` converts a DataFrame with a two-level index to a Panel. - -.. ipython:: python - :okwarning: - - midx = pd.MultiIndex(levels=[['one', 'two'], ['x', 'y']], - codes=[[1, 1, 0, 0], [1, 0, 1, 0]]) - df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [5, 6, 7, 8]}, index=midx) - df.to_panel() - -.. _dsintro.panel_item_selection: - -Item selection / addition / deletion -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Similar to DataFrame functioning as a dict of Series, Panel is like a dict -of DataFrames: - -.. ipython:: python - - wp['Item1'] - wp['Item3'] = wp['Item1'] / wp['Item2'] - -The API for insertion and deletion is the same as for DataFrame. And as with -DataFrame, if the item is a valid Python identifier, you can access it as an -attribute and tab-complete it in IPython. - -Transposing -~~~~~~~~~~~ - -A Panel can be rearranged using its ``transpose`` method (which does not make a -copy by default unless the data are heterogeneous): - -.. ipython:: python - :okwarning: - - wp.transpose(2, 0, 1) - -Indexing / Selection -~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: - :header: "Operation", "Syntax", "Result" - :widths: 30, 20, 10 - - Select item, ``wp[item]``, DataFrame - Get slice at major_axis label, ``wp.major_xs(val)``, DataFrame - Get slice at minor_axis label, ``wp.minor_xs(val)``, DataFrame - -For example, using the earlier example data, we could do: - -.. ipython:: python - - wp['Item1'] - wp.major_xs(wp.major_axis[2]) - wp.minor_axis - wp.minor_xs('C') - -Squeezing -~~~~~~~~~ - -Another way to change the dimensionality of an object is to ``squeeze`` a 1-len -object, similar to ``wp['Item1']``. - -.. ipython:: python - :okwarning: - - wp.reindex(items=['Item1']).squeeze() - wp.reindex(items=['Item1'], minor=['B']).squeeze() - - -Conversion to DataFrame -~~~~~~~~~~~~~~~~~~~~~~~ - -A Panel can be represented in 2D form as a hierarchically indexed -DataFrame. See the section :ref:`hierarchical indexing ` -for more on this. To convert a Panel to a DataFrame, use the ``to_frame`` -method: - -.. ipython:: python - :okwarning: - - panel = pd.Panel(np.random.randn(3, 5, 4), items=['one', 'two', 'three'], - major_axis=pd.date_range('1/1/2000', periods=5), - minor_axis=['a', 'b', 'c', 'd']) - panel.to_frame() diff --git a/doc/source/install.rst b/doc/source/install.rst index 9ecd78c9c19fa..7bcee84ad4025 100644 --- a/doc/source/install.rst +++ b/doc/source/install.rst @@ -255,7 +255,7 @@ Optional Dependencies * `Cython `__: Only necessary to build development version. Version 0.28.2 or higher. * `SciPy `__: miscellaneous statistical functions, Version 0.18.1 or higher -* `xarray `__: pandas like handling for > 2 dims, needed for converting Panels to xarray objects. Version 0.7.0 or higher is recommended. +* `xarray `__: pandas like handling for > 2 dims. Version 0.7.0 or higher is recommended. * `PyTables `__: necessary for HDF5-based storage, Version 3.4.2 or higher * `pyarrow `__ (>= 0.9.0): necessary for feather-based storage. * `Apache Parquet `__, either `pyarrow `__ (>= 0.7.0) or `fastparquet `__ (>= 0.2.1) for parquet-based storage. The `snappy `__ and `brotli `__ are available for compression support. diff --git a/doc/source/reference/index.rst b/doc/source/reference/index.rst index 1e652c9e5497d..31b493e472099 100644 --- a/doc/source/reference/index.rst +++ b/doc/source/reference/index.rst @@ -57,15 +57,6 @@ public functions related to data types in pandas. api/pandas.Index.is_type_compatible api/pandas.Index.nlevels api/pandas.Index.sort - api/pandas.Panel.agg - api/pandas.Panel.aggregate - api/pandas.Panel.blocks - api/pandas.Panel.empty - api/pandas.Panel.is_copy - api/pandas.Panel.items - api/pandas.Panel.ix - api/pandas.Panel.major_axis - api/pandas.Panel.minor_axis api/pandas.Series.asobject api/pandas.Series.blocks api/pandas.Series.from_array diff --git a/doc/source/reference/panel.rst b/doc/source/reference/panel.rst index 39c8ba0828859..94bfe87fe39f0 100644 --- a/doc/source/reference/panel.rst +++ b/doc/source/reference/panel.rst @@ -7,202 +7,4 @@ Panel ===== .. currentmodule:: pandas -Constructor -~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel - -Properties and underlying data -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -**Axes** - -* **items**: axis 0; each item corresponds to a DataFrame contained inside -* **major_axis**: axis 1; the index (rows) of each of the DataFrames -* **minor_axis**: axis 2; the columns of each of the DataFrames - -.. autosummary:: - :toctree: api/ - - Panel.values - Panel.axes - Panel.ndim - Panel.size - Panel.shape - Panel.dtypes - Panel.ftypes - Panel.get_dtype_counts - Panel.get_ftype_counts - -Conversion -~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.astype - Panel.copy - Panel.isna - Panel.notna - -Getting and setting -~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.get_value - Panel.set_value - -Indexing, iteration, slicing -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.at - Panel.iat - Panel.loc - Panel.iloc - Panel.__iter__ - Panel.iteritems - Panel.pop - Panel.xs - Panel.major_xs - Panel.minor_xs - -For more information on ``.at``, ``.iat``, ``.loc``, and -``.iloc``, see the :ref:`indexing documentation `. - -Binary operator functions -~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.add - Panel.sub - Panel.mul - Panel.div - Panel.truediv - Panel.floordiv - Panel.mod - Panel.pow - Panel.radd - Panel.rsub - Panel.rmul - Panel.rdiv - Panel.rtruediv - Panel.rfloordiv - Panel.rmod - Panel.rpow - Panel.lt - Panel.gt - Panel.le - Panel.ge - Panel.ne - Panel.eq - -Function application, GroupBy -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.apply - Panel.groupby - -.. _api.panel.stats: - -Computations / Descriptive Stats -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.abs - Panel.clip - Panel.clip_lower - Panel.clip_upper - Panel.count - Panel.cummax - Panel.cummin - Panel.cumprod - Panel.cumsum - Panel.max - Panel.mean - Panel.median - Panel.min - Panel.pct_change - Panel.prod - Panel.sem - Panel.skew - Panel.sum - Panel.std - Panel.var - -Reindexing / Selection / Label manipulation -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.add_prefix - Panel.add_suffix - Panel.drop - Panel.equals - Panel.filter - Panel.first - Panel.last - Panel.reindex - Panel.reindex_axis - Panel.reindex_like - Panel.rename - Panel.sample - Panel.select - Panel.take - Panel.truncate - -Missing data handling -~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.dropna - -Reshaping, sorting, transposing -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.sort_index - Panel.swaplevel - Panel.transpose - Panel.swapaxes - Panel.conform - -Combining / joining / merging -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.join - Panel.update - -Time series-related -~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.asfreq - Panel.shift - Panel.resample - Panel.tz_convert - Panel.tz_localize - -Serialization / IO / Conversion -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree: api/ - - Panel.from_dict - Panel.to_pickle - Panel.to_excel - Panel.to_hdf - Panel.to_sparse - Panel.to_frame - Panel.to_clipboard +`Panel` was removed in 0.25.0. For prior documentation, see the `0.24 documentation `_ diff --git a/doc/source/user_guide/computation.rst b/doc/source/user_guide/computation.rst index 95142a7b83435..c96e066a5874b 100644 --- a/doc/source/user_guide/computation.rst +++ b/doc/source/user_guide/computation.rst @@ -13,7 +13,7 @@ Statistical Functions Percent Change ~~~~~~~~~~~~~~ -``Series``, ``DataFrame``, and ``Panel`` all have a method +``Series`` and ``DataFrame`` have a method :meth:`~DataFrame.pct_change` to compute the percent change over a given number of periods (using ``fill_method`` to fill NA/null values *before* computing the percent change). @@ -574,11 +574,6 @@ For example: Computing rolling pairwise covariances and correlations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. warning:: - - Prior to version 0.20.0 if ``pairwise=True`` was passed, a ``Panel`` would be returned. - This will now return a 2-level MultiIndexed DataFrame, see the whatsnew :ref:`here `. - In financial data analysis and other fields it's common to compute covariance and correlation matrices for a collection of time series. Often one is also interested in moving-window covariance and correlation matrices. This can be diff --git a/doc/source/user_guide/cookbook.rst b/doc/source/user_guide/cookbook.rst index 0f9726dc94816..f724d975560e7 100644 --- a/doc/source/user_guide/cookbook.rst +++ b/doc/source/user_guide/cookbook.rst @@ -245,30 +245,6 @@ Ambiguity arises when an index consists of integers with a non-zero start or non df[~((df.AAA <= 6) & (df.index.isin([0, 2, 4])))] -Panels -****** - -`Extend a panel frame by transposing, adding a new dimension, and transposing back to the original dimensions -`__ - -.. ipython:: python - - rng = pd.date_range('1/1/2013', periods=100, freq='D') - data = np.random.randn(100, 4) - cols = ['A', 'B', 'C', 'D'] - df1 = pd.DataFrame(data, rng, cols) - df2 = pd.DataFrame(data, rng, cols) - df3 = pd.DataFrame(data, rng, cols) - - pf = pd.Panel({'df1': df1, 'df2': df2, 'df3': df3}) - pf - - pf.loc[:, :, 'F'] = pd.DataFrame(data, rng, cols) - pf - -`Mask a panel by using np.where and then reconstructing the panel with the new masked values -`__ - New Columns *********** diff --git a/doc/source/user_guide/indexing.rst b/doc/source/user_guide/indexing.rst index 00d4dc9efc8cc..ca788963971ad 100644 --- a/doc/source/user_guide/indexing.rst +++ b/doc/source/user_guide/indexing.rst @@ -64,7 +64,7 @@ of multi-axis indexing. index! See :ref:`Slicing with labels `.). * A boolean array - * A ``callable`` function with one argument (the calling Series, DataFrame or Panel) and + * A ``callable`` function with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above). .. versionadded:: 0.18.1 @@ -82,7 +82,7 @@ of multi-axis indexing. * A list or array of integers ``[4, 3, 0]``. * A slice object with ints ``1:7``. * A boolean array. - * A ``callable`` function with one argument (the calling Series, DataFrame or Panel) and + * A ``callable`` function with one argument (the calling Series or DataFrame) and that returns valid output for indexing (one of the above). .. versionadded:: 0.18.1 @@ -106,7 +106,6 @@ the specification are assumed to be ``:``, e.g. ``p.loc['a']`` is equivalent to Series; ``s.loc[indexer]`` DataFrame; ``df.loc[row_indexer,column_indexer]`` - Panel; ``p.loc[item_indexer,major_indexer,minor_indexer]`` .. _indexing.basics: @@ -126,7 +125,6 @@ indexing pandas objects with ``[]``: Series; ``series[label]``; scalar value DataFrame; ``frame[colname]``; ``Series`` corresponding to colname - Panel; ``panel[itemname]``; ``DataFrame`` corresponding to the itemname Here we construct a simple time series data set to use for illustrating the indexing functionality: @@ -137,8 +135,6 @@ indexing functionality: df = pd.DataFrame(np.random.randn(8, 4), index=dates, columns=['A', 'B', 'C', 'D']) df - panel = pd.Panel({'one': df, 'two': df - df.mean()}) - panel .. note:: @@ -151,7 +147,6 @@ Thus, as per above, we have the most basic indexing using ``[]``: s = df['A'] s[dates[5]] - panel['two'] You can pass a list of columns to ``[]`` to select columns in that order. If a column is not contained in the DataFrame, an exception will be @@ -195,7 +190,7 @@ Attribute Access .. _indexing.attribute_access: -You may access an index on a ``Series``, column on a ``DataFrame``, and an item on a ``Panel`` directly +You may access an index on a ``Series`` or column on a ``DataFrame`` directly as an attribute: .. ipython:: python @@ -207,7 +202,6 @@ as an attribute: sa.b dfa.A - panel.one .. ipython:: python @@ -545,7 +539,7 @@ Selection By Callable .. versionadded:: 0.18.1 ``.loc``, ``.iloc``, and also ``[]`` indexing can accept a ``callable`` as indexer. -The ``callable`` must be a function with one argument (the calling Series, DataFrame or Panel) that returns valid output for indexing. +The ``callable`` must be a function with one argument (the calling Series or DataFrame) that returns valid output for indexing. .. ipython:: python @@ -741,7 +735,7 @@ However, this would *still* raise if your resulting index is duplicated. Selecting Random Samples ------------------------ -A random selection of rows or columns from a Series, DataFrame, or Panel with the :meth:`~DataFrame.sample` method. The method will sample rows by default, and accepts a specific number of rows/columns to return, or a fraction of rows. +A random selection of rows or columns from a Series or DataFrame with the :meth:`~DataFrame.sample` method. The method will sample rows by default, and accepts a specific number of rows/columns to return, or a fraction of rows. .. ipython:: python @@ -1471,7 +1465,7 @@ The same set of options are available for the ``keep`` parameter. Dictionary-like :meth:`~pandas.DataFrame.get` method ---------------------------------------------------- -Each of Series, DataFrame, and Panel have a ``get`` method which can return a +Each of Series or DataFrame have a ``get`` method which can return a default value. .. ipython:: python diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index f4227de603064..e9a5dad21744b 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -3185,7 +3185,7 @@ argument to ``to_excel`` and to ``ExcelWriter``. The built-in engines are: .. code-block:: python - # By setting the 'engine' in the DataFrame and Panel 'to_excel()' methods. + # By setting the 'engine' in the DataFrame 'to_excel()' methods. df.to_excel('path_to_file.xlsx', sheet_name='Sheet1', engine='xlsxwriter') # By setting the 'engine' in the ExcelWriter constructor. @@ -3474,20 +3474,12 @@ dict: s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e']) df = pd.DataFrame(np.random.randn(8, 3), index=index, columns=['A', 'B', 'C']) - wp = pd.Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'], - major_axis=pd.date_range('1/1/2000', periods=5), - minor_axis=['A', 'B', 'C', 'D']) # store.put('s', s) is an equivalent method store['s'] = s store['df'] = df - store['wp'] = wp - - # the type of stored data - store.root.wp._v_attrs.pandas_type - store In a current or later Python session, you can retrieve stored objects: @@ -3504,8 +3496,8 @@ Deletion of the object specified by the key: .. ipython:: python - # store.remove('wp') is an equivalent method - del store['wp'] + # store.remove('df') is an equivalent method + del store['df'] store @@ -3572,28 +3564,6 @@ HDFStore will by default not drop rows that are all missing. This behavior can b os.remove('file.h5') -This is also true for the major axis of a ``Panel``: - -.. ipython:: python - - matrix = [[[np.nan, np.nan, np.nan], [1, np.nan, np.nan]], - [[np.nan, np.nan, np.nan], [np.nan, 5, 6]], - [[np.nan, np.nan, np.nan], [np.nan, 3, np.nan]]] - - panel_with_major_axis_all_missing = pd.Panel(matrix, - items=['Item1', 'Item2', 'Item3'], - major_axis=[1, 2], - minor_axis=['A', 'B', 'C']) - - panel_with_major_axis_all_missing - - panel_with_major_axis_all_missing.to_hdf('file.h5', 'panel', - dropna=True, - format='table', - mode='w') - reloaded = pd.read_hdf('file.h5', 'panel') - reloaded - .. ipython:: python :suppress: @@ -3815,8 +3785,6 @@ data. A query is specified using the ``Term`` class under the hood, as a boolean expression. * ``index`` and ``columns`` are supported indexers of a ``DataFrames``. -* ``major_axis``, ``minor_axis``, and ``items`` are supported indexers of - the Panel. * if ``data_columns`` are specified, these can be used as additional indexers. Valid comparison operators are: @@ -3914,15 +3882,6 @@ Use and inline column reference store.select('dfq', where="A>0 or C>0") -Works with a Panel as well. - -.. ipython:: python - - store.append('wp', wp) - store - store.select('wp', - "major_axis>pd.Timestamp('20000102') & minor_axis=['A', 'B']") - The ``columns`` keyword can be supplied to select a list of columns to be returned, this is equivalent to passing a ``'columns=list_of_columns_to_filter'``: @@ -3934,15 +3893,6 @@ returned, this is equivalent to passing a ``start`` and ``stop`` parameters can be specified to limit the total search space. These are in terms of the total number of rows in a table. -.. ipython:: python - - # this is effectively what the storage of a Panel looks like - wp.to_frame() - - # limiting the search - store.select('wp', "major_axis>20000102 & minor_axis=['A', 'B']", - start=0, stop=10) - .. note:: ``select`` will raise a ``ValueError`` if the query expression has an unknown @@ -4235,8 +4185,7 @@ You can delete from a table selectively by specifying a ``where``. In deleting rows, it is important to understand the ``PyTables`` deletes rows by erasing the rows, then **moving** the following data. Thus deleting can potentially be a very expensive operation depending on the -orientation of your data. This is especially true in higher dimensional -objects (``Panel`` and ``Panel4D``). To get optimal performance, it's +orientation of your data. To get optimal performance, it's worthwhile to have the dimension you are deleting be the first of the ``indexables``. @@ -4261,12 +4210,6 @@ the other hand a delete operation on the ``minor_axis`` will be very expensive. In this case it would almost certainly be faster to rewrite the table using a ``where`` that selects all but the missing data. -.. ipython:: python - - # returns the number of rows deleted - store.remove('wp', 'major_axis > 20000102') - store.select('wp') - .. warning:: Please note that HDF5 **DOES NOT RECLAIM SPACE** in the h5 files @@ -4384,7 +4327,7 @@ Caveats * If you use locks to manage write access between multiple processes, you may want to use :py:func:`~os.fsync` before releasing write locks. For convenience you can use ``store.flush(fsync=True)`` to do this for you. -* Once a ``table`` is created its items (Panel) / columns (DataFrame) +* Once a ``table`` is created columns (DataFrame) are fixed; only exactly the same columns can be appended * Be aware that timezones (e.g., ``pytz.timezone('US/Eastern')``) are not necessarily equal across timezone versions. So if data is diff --git a/doc/source/user_guide/merging.rst b/doc/source/user_guide/merging.rst index c97935803619a..25c486c839b7f 100644 --- a/doc/source/user_guide/merging.rst +++ b/doc/source/user_guide/merging.rst @@ -14,8 +14,8 @@ Merge, join, and concatenate **************************** -pandas provides various facilities for easily combining together Series, -DataFrame, and Panel objects with various kinds of set logic for the indexes +pandas provides various facilities for easily combining together Series or +DataFrame with various kinds of set logic for the indexes and relational algebra functionality in the case of join / merge-type operations. @@ -74,7 +74,7 @@ some configurable handling of "what to do with the other axes": keys=None, levels=None, names=None, verify_integrity=False, copy=True) -* ``objs`` : a sequence or mapping of Series, DataFrame, or Panel objects. If a +* ``objs`` : a sequence or mapping of Series or DataFrame objects. If a dict is passed, the sorted keys will be used as the `keys` argument, unless it is passed, in which case the values will be selected (see below). Any None objects will be dropped silently unless they are all None in which case a @@ -1284,8 +1284,8 @@ similarly. .. _merging.multiple_join: -Joining multiple DataFrame or Panel objects -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Joining multiple DataFrames +~~~~~~~~~~~~~~~~~~~~~~~~~~~ A list or tuple of ``DataFrames`` can also be passed to :meth:`~DataFrame.join` to join them together on their indexes. diff --git a/doc/source/user_guide/sparse.rst b/doc/source/user_guide/sparse.rst index 540e52fc2b08a..20962749e2040 100644 --- a/doc/source/user_guide/sparse.rst +++ b/doc/source/user_guide/sparse.rst @@ -6,8 +6,6 @@ Sparse data structures ********************** -.. note:: The ``SparsePanel`` class has been removed in 0.19.0 - We have implemented "sparse" versions of ``Series`` and ``DataFrame``. These are not sparse in the typical "mostly 0". Rather, you can view these objects as being "compressed" where any data matching a specific value (``NaN`` / missing value, though any value diff --git a/doc/source/whatsnew/v0.20.0.rst b/doc/source/whatsnew/v0.20.0.rst index 26fdee4685c4b..ceec4c3615216 100644 --- a/doc/source/whatsnew/v0.20.0.rst +++ b/doc/source/whatsnew/v0.20.0.rst @@ -1356,7 +1356,7 @@ Deprecate Panel ``Panel`` is deprecated and will be removed in a future version. The recommended way to represent 3-D data are with a ``MultiIndex`` on a ``DataFrame`` via the :meth:`~Panel.to_frame` or with the `xarray package `__. Pandas -provides a :meth:`~Panel.to_xarray` method to automate this conversion. For more details see :ref:`Deprecate Panel ` documentation. (:issue:`13563`). +provides a :meth:`~Panel.to_xarray` method to automate this conversion (:issue:`13563`). .. code-block:: ipython diff --git a/doc/source/whatsnew/v0.23.0.rst b/doc/source/whatsnew/v0.23.0.rst index 7ec5a39c3d384..98479fa30eb15 100644 --- a/doc/source/whatsnew/v0.23.0.rst +++ b/doc/source/whatsnew/v0.23.0.rst @@ -644,7 +644,7 @@ Deprecate Panel ``Panel`` was deprecated in the 0.20.x release, showing as a ``DeprecationWarning``. Using ``Panel`` will now show a ``FutureWarning``. The recommended way to represent 3-D data are with a ``MultiIndex`` on a ``DataFrame`` via the :meth:`~Panel.to_frame` or with the `xarray package `__. Pandas -provides a :meth:`~Panel.to_xarray` method to automate this conversion. For more details see :ref:`Deprecate Panel ` documentation. (:issue:`13563`, :issue:`18324`). +provides a :meth:`~Panel.to_xarray` method to automate this conversion (:issue:`13563`, :issue:`18324`). .. code-block:: ipython diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 73eb6a15a1b47..843d70fea5416 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -8,6 +8,11 @@ What's New in 0.25.0 (April XX, 2019) Starting with the 0.25.x series of releases, pandas only supports Python 3.5 and higher. See :ref:`install.dropping-27` for more details. +.. warning:: + + `Panel` has been fully removed. For N-D labeled data structures, please + use `xarray `_ + {{ header }} These are the changes in pandas 0.25.0. See :ref:`release` for a full changelog diff --git a/doc/source/whatsnew/v0.6.0.rst b/doc/source/whatsnew/v0.6.0.rst index ba2c6aec40f50..c0aba18d08b27 100644 --- a/doc/source/whatsnew/v0.6.0.rst +++ b/doc/source/whatsnew/v0.6.0.rst @@ -24,7 +24,7 @@ New Features - :ref:`Added ` ``Series.mad``, mean absolute deviation - :ref:`Added ` ``QuarterEnd`` DateOffset (:issue:`321`) - :ref:`Added ` ``dot`` to DataFrame (:issue:`65`) -- :ref:`Added ` ``orient`` option to ``Panel.from_dict`` (:issue:`359`, :issue:`301`) +- Added ``orient`` option to ``Panel.from_dict`` (:issue:`359`, :issue:`301`) - :ref:`Added ` ``orient`` option to ``DataFrame.from_dict`` - :ref:`Added ` passing list of tuples or list of lists to ``DataFrame.from_records`` (:issue:`357`) - :ref:`Added ` multiple levels to groupby (:issue:`103`) diff --git a/doc/source/whatsnew/v0.7.0.rst b/doc/source/whatsnew/v0.7.0.rst index d63b4a3cb4df1..deff214354e2b 100644 --- a/doc/source/whatsnew/v0.7.0.rst +++ b/doc/source/whatsnew/v0.7.0.rst @@ -45,7 +45,7 @@ New features - :ref:`Add` ``DataFrame.iterrows`` method for efficiently iterating through the rows of a DataFrame -- :ref:`Add` ``DataFrame.to_panel`` with code adapted from +- Add ``DataFrame.to_panel`` with code adapted from ``LongPanel.to_long`` - :ref:`Add ` ``reindex_axis`` method added to DataFrame @@ -57,7 +57,7 @@ New features and ``align`` methods on Series and DataFrame for broadcasting values across a level (:issue:`542`, :issue:`552`, others) -- :ref:`Add ` attribute-based item access to +- Add attribute-based item access to ``Panel`` and add IPython completion (:issue:`563`) - :ref:`Add ` ``logy`` option to ``Series.plot`` for @@ -81,7 +81,7 @@ New features - :ref:`Can ` pass MaskedArray to Series constructor (:issue:`563`) -- :ref:`Add ` Panel item access via attributes +- Add Panel item access via attributes and IPython completion (:issue:`554`) - Implement ``DataFrame.lookup``, fancy-indexing analogue for retrieving values diff --git a/pandas/core/frame.py b/pandas/core/frame.py index b4f15905afc44..d3029edca9dc9 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -370,6 +370,7 @@ def _constructor(self): @property def _constructor_expanddim(self): + # TODO: Raise NotImplementedError or change note in extending.rst from pandas.core.panel import Panel return Panel