-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the pandas.Index.is_categorical docstring #20167
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
TomAugspurger
merged 7 commits into
pandas-dev:master
from
mariadelmarbibiloni:docstring_Index.is_categorical
Mar 12, 2018
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
354795e
pandas.Index.is_categorical from base.py documented
mariadelmarbibiloni 1755bee
pandas.Index.is_categorical from base.py documented and some errors s…
mariadelmarbibiloni 5a972b4
pandas.Index.is_categorical from base.py with new examples and extend…
mariadelmarbibiloni e6e12c6
Added See Also.
TomAugspurger a4586f2
Added back whitepace
TomAugspurger 218737a
to_frame formatting
TomAugspurger 1461f4a
Merge remote-tracking branch 'upstream/master' into mariadelmarbibilo…
TomAugspurger 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 |
---|---|---|
|
@@ -1156,7 +1156,7 @@ def to_frame(self, index=True): | |
>>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal') | ||
>>> idx.to_frame() | ||
animal | ||
animal | ||
animal | ||
Ant Ant | ||
Bear Bear | ||
Cow Cow | ||
|
@@ -1471,6 +1471,39 @@ def is_object(self): | |
return is_object_dtype(self.dtype) | ||
|
||
def is_categorical(self): | ||
""" | ||
Check if the Index holds categorical data. | ||
|
||
Returns | ||
------- | ||
boolean | ||
True if the Index is categorical. | ||
|
||
See Also | ||
-------- | ||
CategoricalIndex : Index for categorical data. | ||
|
||
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. Thanks a lot for the See Also! |
||
Examples | ||
-------- | ||
>>> idx = pd.Index(["Watermelon", "Orange", "Apple", | ||
... "Watermelon"]).astype("category") | ||
>>> idx.is_categorical() | ||
True | ||
|
||
>>> idx = pd.Index([1, 3, 5, 7]) | ||
>>> idx.is_categorical() | ||
False | ||
|
||
>>> s = pd.Series(["Peter", "Víctor", "Elisabeth", "Mar"]) | ||
>>> s | ||
0 Peter | ||
1 Víctor | ||
2 Elisabeth | ||
3 Mar | ||
dtype: object | ||
>>> s.index.is_categorical() | ||
False | ||
""" | ||
return self.inferred_type in ['categorical'] | ||
|
||
def is_interval(self): | ||
|
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.
I agree! Thank you :)