Skip to content

Commit 2105e81

Browse files
authored
DEPR: subclassing Index (#52186)
* DEPR: subclassing Index * move whatsnew * warning * whitespace
1 parent 323ed9b commit 2105e81

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

doc/source/development/internals.rst

+3-25
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,9 @@ There are functions that make the creation of a regular index easy:
3131
* :func:`period_range`: fixed frequency date range generated from a time rule or
3232
DateOffset. An ndarray of :class:`Period` objects, representing timespans
3333

34-
The motivation for having an ``Index`` class in the first place was to enable
35-
different implementations of indexing. This means that it's possible for you,
36-
the user, to implement a custom ``Index`` subclass that may be better suited to
37-
a particular application than the ones provided in pandas.
38-
39-
From an internal implementation point of view, the relevant methods that an
40-
``Index`` must define are one or more of the following (depending on how
41-
incompatible the new object internals are with the ``Index`` functions):
42-
43-
* :meth:`~Index.get_loc`: returns an "indexer" (an integer, or in some cases a
44-
slice object) for a label
45-
* :meth:`~Index.slice_locs`: returns the "range" to slice between two labels
46-
* :meth:`~Index.get_indexer`: Computes the indexing vector for reindexing / data
47-
alignment purposes. See the source / docstrings for more on this
48-
* :meth:`~Index.get_indexer_non_unique`: Computes the indexing vector for reindexing / data
49-
alignment purposes when the index is non-unique. See the source / docstrings
50-
for more on this
51-
* :meth:`~Index.reindex`: Does any pre-conversion of the input index then calls
52-
``get_indexer``
53-
* :meth:`~Index.union`, :meth:`~Index.intersection`: computes the union or intersection of two
54-
Index objects
55-
* :meth:`~Index.insert`: Inserts a new label into an Index, yielding a new object
56-
* :meth:`~Index.delete`: Delete a label, yielding a new object
57-
* :meth:`~Index.drop`: Deletes a set of labels
58-
* :meth:`~Index.take`: Analogous to ndarray.take
34+
.. warning::
35+
36+
Custom :class:`Index` subclasses are not supported, custom behavior should be implemented using the :class:`ExtensionArray` interface instead.
5937

6038
MultiIndex
6139
~~~~~~~~~~

doc/source/whatsnew/v2.1.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Deprecations
105105
- Deprecated :meth:`.Groupby.all` and :meth:`.GroupBy.any` with datetime64 or :class:`PeriodDtype` values, matching the :class:`Series` and :class:`DataFrame` deprecations (:issue:`34479`)
106106
- 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`)
107107
- 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`)
108+
- Deprecated explicit support for subclassing :class:`Index` (:issue:`45289`)
108109
- Deprecated :meth:`DataFrameGroupBy.dtypes`, check ``dtypes`` on the underlying object instead (:issue:`51045`)
109110
- Deprecated ``axis=1`` in :meth:`DataFrame.groupby` and in :class:`Grouper` constructor, do ``frame.T.groupby(...)`` instead (:issue:`51203`)
110111
- Deprecated :meth:`Categorical.to_list`, use ``obj.tolist()`` instead (:issue:`51254`)

0 commit comments

Comments
 (0)