From 68339a090c58aaf4830d67f20b590cab8f4406d8 Mon Sep 17 00:00:00 2001 From: Brock Date: Fri, 24 Mar 2023 15:02:42 -0700 Subject: [PATCH 1/4] DEPR: subclassing Index --- doc/source/development/internals.rst | 26 -------------------------- doc/source/whatsnew/v2.1.0.rst | 1 + 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/doc/source/development/internals.rst b/doc/source/development/internals.rst index 3dd687ef2087d..1c6ca93f79666 100644 --- a/doc/source/development/internals.rst +++ b/doc/source/development/internals.rst @@ -31,32 +31,6 @@ There are functions that make the creation of a regular index easy: * :func:`period_range`: fixed frequency date range generated from a time rule or DateOffset. An ndarray of :class:`Period` objects, representing timespans -The motivation for having an ``Index`` class in the first place was to enable -different implementations of indexing. This means that it's possible for you, -the user, to implement a custom ``Index`` subclass that may be better suited to -a particular application than the ones provided in pandas. - -From an internal implementation point of view, the relevant methods that an -``Index`` must define are one or more of the following (depending on how -incompatible the new object internals are with the ``Index`` functions): - -* :meth:`~Index.get_loc`: returns an "indexer" (an integer, or in some cases a - slice object) for a label -* :meth:`~Index.slice_locs`: returns the "range" to slice between two labels -* :meth:`~Index.get_indexer`: Computes the indexing vector for reindexing / data - alignment purposes. See the source / docstrings for more on this -* :meth:`~Index.get_indexer_non_unique`: Computes the indexing vector for reindexing / data - alignment purposes when the index is non-unique. See the source / docstrings - for more on this -* :meth:`~Index.reindex`: Does any pre-conversion of the input index then calls - ``get_indexer`` -* :meth:`~Index.union`, :meth:`~Index.intersection`: computes the union or intersection of two - Index objects -* :meth:`~Index.insert`: Inserts a new label into an Index, yielding a new object -* :meth:`~Index.delete`: Delete a label, yielding a new object -* :meth:`~Index.drop`: Deletes a set of labels -* :meth:`~Index.take`: Analogous to ndarray.take - MultiIndex ~~~~~~~~~~ diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 1f5c3c88c5ff5..4e0334799fae3 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -114,6 +114,7 @@ Deprecations - Deprecated 'method', 'limit', and 'fill_axis' keywords in :meth:`DataFrame.align` and :meth:`Series.align`, explicitly call ``fillna`` on the alignment results instead (:issue:`51856`) - Deprecated 'broadcast_axis' keyword in :meth:`Series.align` and :meth:`DataFrame.align`, upcast before calling ``align`` with ``left = DataFrame({col: left for col in right.columns}, index=right.index)`` (:issue:`51856`) - Deprecated the 'axis' keyword in :meth:`.GroupBy.idxmax`, :meth:`.GroupBy.idxmin`, :meth:`.GroupBy.fillna`, :meth:`.GroupBy.take`, :meth:`.GroupBy.skew`, :meth:`.GroupBy.rank`, :meth:`.GroupBy.cumprod`, :meth:`.GroupBy.cumsum`, :meth:`.GroupBy.cummax`, :meth:`.GroupBy.cummin`, :meth:`.GroupBy.pct_change`, :meth:`GroupBy.diff`, :meth:`.GroupBy.shift`, and :meth:`DataFrameGroupBy.corrwith`; for ``axis=1`` operate on the underlying :class:`DataFrame` instead (:issue:`50405`, :issue:`51046`) +- Deprecated explicit support for subclassing :class:`Index` (:issue:`45289`) - .. --------------------------------------------------------------------------- From ea623330e4b835c115a0dedad7e3a966679e04a9 Mon Sep 17 00:00:00 2001 From: Brock Date: Fri, 24 Mar 2023 15:03:00 -0700 Subject: [PATCH 2/4] move whatsnew --- doc/source/whatsnew/v2.1.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 4e0334799fae3..ea3892284f2ef 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -103,6 +103,7 @@ Deprecations - Deprecated :meth:`.Groupby.all` and :meth:`.GroupBy.any` with datetime64 or :class:`PeriodDtype` values, matching the :class:`Series` and :class:`DataFrame` deprecations (:issue:`34479`) - Deprecating pinning ``group.name`` to each group in :meth:`SeriesGroupBy.aggregate` aggregations; if your operation requires utilizing the groupby keys, iterate over the groupby object instead (:issue:`41090`) - Deprecated the default of ``observed=False`` in :meth:`DataFrame.groupby` and :meth:`Series.groupby`; this will default to ``True`` in a future version (:issue:`43999`) +- Deprecated explicit support for subclassing :class:`Index` (:issue:`45289`) - Deprecated :meth:`DataFrameGroupBy.dtypes`, check ``dtypes`` on the underlying object instead (:issue:`51045`) - Deprecated ``axis=1`` in :meth:`DataFrame.groupby` and in :class:`Grouper` constructor, do ``frame.T.groupby(...)`` instead (:issue:`51203`) - Deprecated :meth:`Categorical.to_list`, use ``obj.tolist()`` instead (:issue:`51254`) @@ -114,7 +115,6 @@ Deprecations - Deprecated 'method', 'limit', and 'fill_axis' keywords in :meth:`DataFrame.align` and :meth:`Series.align`, explicitly call ``fillna`` on the alignment results instead (:issue:`51856`) - Deprecated 'broadcast_axis' keyword in :meth:`Series.align` and :meth:`DataFrame.align`, upcast before calling ``align`` with ``left = DataFrame({col: left for col in right.columns}, index=right.index)`` (:issue:`51856`) - Deprecated the 'axis' keyword in :meth:`.GroupBy.idxmax`, :meth:`.GroupBy.idxmin`, :meth:`.GroupBy.fillna`, :meth:`.GroupBy.take`, :meth:`.GroupBy.skew`, :meth:`.GroupBy.rank`, :meth:`.GroupBy.cumprod`, :meth:`.GroupBy.cumsum`, :meth:`.GroupBy.cummax`, :meth:`.GroupBy.cummin`, :meth:`.GroupBy.pct_change`, :meth:`GroupBy.diff`, :meth:`.GroupBy.shift`, and :meth:`DataFrameGroupBy.corrwith`; for ``axis=1`` operate on the underlying :class:`DataFrame` instead (:issue:`50405`, :issue:`51046`) -- Deprecated explicit support for subclassing :class:`Index` (:issue:`45289`) - .. --------------------------------------------------------------------------- From b5c98ccbb2b9936a14dea0b54d3fa6d1cd2cdb21 Mon Sep 17 00:00:00 2001 From: Brock Date: Mon, 27 Mar 2023 14:50:30 -0700 Subject: [PATCH 3/4] warning --- doc/source/development/internals.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/development/internals.rst b/doc/source/development/internals.rst index 1c6ca93f79666..d078de4f2b64f 100644 --- a/doc/source/development/internals.rst +++ b/doc/source/development/internals.rst @@ -31,6 +31,9 @@ There are functions that make the creation of a regular index easy: * :func:`period_range`: fixed frequency date range generated from a time rule or DateOffset. An ndarray of :class:`Period` objects, representing timespans +.. warning:: Custom :class:`Index` subclasses are not supported, custom behavior should +be implemented using the :class:`ExtensionArray` interface instead. + MultiIndex ~~~~~~~~~~ From 870149f8eb5266f323fbcaeb68490dc37b0643e3 Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 28 Mar 2023 12:28:52 -0700 Subject: [PATCH 4/4] whitespace --- doc/source/development/internals.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/development/internals.rst b/doc/source/development/internals.rst index d078de4f2b64f..e3468746ce177 100644 --- a/doc/source/development/internals.rst +++ b/doc/source/development/internals.rst @@ -31,8 +31,9 @@ There are functions that make the creation of a regular index easy: * :func:`period_range`: fixed frequency date range generated from a time rule or DateOffset. An ndarray of :class:`Period` objects, representing timespans -.. warning:: Custom :class:`Index` subclasses are not supported, custom behavior should -be implemented using the :class:`ExtensionArray` interface instead. +.. warning:: + + Custom :class:`Index` subclasses are not supported, custom behavior should be implemented using the :class:`ExtensionArray` interface instead. MultiIndex ~~~~~~~~~~