-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
DOC: CategoricalIndex doc string #24852
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
178040e
DOC: CategoricalIndex doc string
topper-123 77de1da
Some fixes to doc string
topper-123 db97ee2
Some fixes to doc string II
topper-123 c2be150
fixups
jorisvandenbossche 76970f3
Merge remote-tracking branch 'upstream/master' into topper-123-Catego…
jorisvandenbossche 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 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 |
---|---|---|
|
@@ -42,26 +42,44 @@ | |
typ='method', overwrite=True) | ||
class CategoricalIndex(Index, accessor.PandasDelegate): | ||
""" | ||
Immutable Index implementing an ordered, sliceable set. CategoricalIndex | ||
represents a sparsely populated Index with an underlying Categorical. | ||
Immutable index implementing an ordered, sliceable set. CategoricalIndex | ||
represents a sparsely populated index with an underlying | ||
:class:`Categorical`. | ||
|
||
`CategoricalIndex`, like `Categorical` can only take on a limited, | ||
and usually fixed, number of possible values (`categories`). Also, | ||
like `Categorical`, it might have an order, but numerical operations | ||
(additions, divisions, ...) are not possible. | ||
|
||
Parameters | ||
---------- | ||
data : array-like or Categorical, (1-dimensional) | ||
categories : optional, array-like | ||
categories for the CategoricalIndex | ||
ordered : boolean, | ||
designating if the categories are ordered | ||
copy : bool | ||
data : list-like | ||
The values of the categorical. If categories are given, values not in | ||
categories will be replaced with NaN. | ||
categories : index-like, optional | ||
The categories for the categorical. Items need to be unique. | ||
If the categories are not given here, then they must be provided | ||
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. If they are not give here (and also not in dtype), they will actually be inferred from the data |
||
in `dtype`. | ||
ordered : bool, optional | ||
Whether or not this categorical is treated as an ordered | ||
categorical. If not given here or in `dtype`, the resulting | ||
categorical will be unordered. | ||
dtype : CategoricalDtype or the string "category", optional | ||
If :class:`CategoricalDtype`, cannot be used together with | ||
`categories` or `ordered`. | ||
|
||
.. versionadded:: 0.21.0 | ||
WillAyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
copy : bool, default False | ||
Make a copy of input ndarray | ||
name : object | ||
name : object, optional | ||
Name to be stored in the index | ||
|
||
Attributes | ||
---------- | ||
codes | ||
categories | ||
ordered | ||
dtype | ||
|
||
Methods | ||
------- | ||
|
@@ -75,9 +93,46 @@ class CategoricalIndex(Index, accessor.PandasDelegate): | |
as_unordered | ||
map | ||
|
||
Raises | ||
------ | ||
ValueError | ||
If the categories do not validate. | ||
TypeError | ||
If an explicit ``ordered=True`` is given but no `categories` and the | ||
`values` are not sortable. | ||
|
||
See Also | ||
-------- | ||
Categorical, Index | ||
Index : The base pandas Index type | ||
Categorical : A categorical variable in classic R / S-plus fashion | ||
CategoricalDtype : Type for categorical data | ||
|
||
Notes | ||
----- | ||
See the `user guide | ||
<https://pandas-docs.github.io/pandas-docs-travis/advanced.html#categoricalindex>`_ | ||
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. let's point here to the stable docs |
||
for more. | ||
|
||
Examples | ||
-------- | ||
>>> pd.CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c']) | ||
CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category') # noqa | ||
|
||
``CategoricalIndex`` can also be instantiated from a ``Categorical``: | ||
|
||
>>> c = pd.Categorical(['a', 'b', 'c', 'a', 'b', 'c']) | ||
>>> pd.CategoricalIndex(c) | ||
CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category') # noqa | ||
|
||
Ordered `CategoricalIndex` can be sorted according to the custom order | ||
of the categories and can have a min and max value. | ||
|
||
>>> ci = pd.CategoricalIndex(['a','b','c','a','b','c'], ordered=True, | ||
... categories=['c', 'b', 'a']) | ||
>>> ci | ||
CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'], categories=['c', 'b', 'a'], ordered=True, dtype='category') # noqa | ||
>>> ci.min() | ||
'c' | ||
""" | ||
|
||
_typ = 'categoricalindex' | ||
|
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.
Short summary should fit on one line
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.
Ok, made a shorter version.