-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: subclassing Index #52186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mroeschke
merged 6 commits into
pandas-dev:main
from
jbrockmendel:depr-index-subclassing
Mar 29, 2023
Merged
DEPR: subclassing Index #52186
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
68339a0
DEPR: subclassing Index
jbrockmendel ea62333
move whatsnew
jbrockmendel b6cd8e6
Merge branch 'main' into depr-index-subclassing
jbrockmendel b5c98cc
warning
jbrockmendel 1bc9704
Merge branch 'main' into depr-index-subclassing
jbrockmendel 870149f
whitespace
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,31 +31,8 @@ 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 | ||
.. warning:: Custom :class:`Index` subclasses are not supported, custom behavior should | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The doc build is failing since the note should start on a new line and indented (similar to |
||
be implemented using the :class:`ExtensionArray` interface instead. | ||
|
||
MultiIndex | ||
~~~~~~~~~~ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to add a
.. warning::
block here noting that subclassing an Index is not officially supported and users should use the extension array interface instead