-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
DOC: Fixed the doctsring for _set_axis_name (GH 22895) #22969
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
jreback
merged 15 commits into
pandas-dev:master
from
bkjchoi72:GH22895_fix_docstring_for_set_axis_name
Nov 20, 2018
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a5fd1c3
DOC: Fixed the doctsring for _set_axis_name (GH 22895)
bkjchoi72 5dbbbd1
Added a new line after the first triple quotes
bkjchoi72 bc865d4
Removed the new line after the first triple quotes
bkjchoi72 457c58e
Merge branch 'master' into GH22895_fix_docstring_for_set_axis_name
bkjchoi72 e469e4e
Merge branch 'master' into GH22895_fix_docstring_for_set_axis_name
bkjchoi72 7fb8a52
Merge branch 'master' into GH22895_fix_docstring_for_set_axis_name
bkjchoi72 067fa8d
Modified the description of parameters. Changed the example to animals.
bkjchoi72 71f3909
Modified the example for DataFrame.rename_axis()
bkjchoi72 a7eb3d8
Changed the example so that it makes sense
bkjchoi72 96a5dd1
Fixed the indentation and changed the word "alter" to "set" where app…
bkjchoi72 22ef507
Merge branch 'master' into GH22895_fix_docstring_for_set_axis_name
bkjchoi72 b030a6b
Fixed failing docstring test
bkjchoi72 6d76d44
Merge branch 'master' into GH22895_fix_docstring_for_set_axis_name
bkjchoi72 adc2694
Adjusted indentation
bkjchoi72 9d944e8
Merging from master and fixing validation issues in the rename_axis d…
datapythonista 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
Changed the example so that it makes sense
- Loading branch information
commit a7eb3d8121a32119f2b0974e8b1f9234d1c6206f
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 |
---|---|---|
|
@@ -1164,22 +1164,24 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False): | |
|
||
**DataFrame** | ||
|
||
>>> df = pd.DataFrame({"name": ["dog", "cat", "monkey"], "legs": [4, 4, 2]}) | ||
name legs | ||
0 dog 4 | ||
1 cat 4 | ||
2 monkey 2 | ||
>>> df = pd.DataFrame({"num_legs": [4, 4, 2], | ||
... "num_arms": [0, 0, 2]}, | ||
... ["dog", "cat", "monkey"]) | ||
num_legs num_arms | ||
dog 4 0 | ||
cat 4 0 | ||
monkey 2 2 | ||
>>> df.rename_axis("animal") | ||
name legs | ||
num_legs num_arms | ||
animal | ||
0 dog 4 | ||
1 cat 4 | ||
2 monkey 2 | ||
>>> df.rename_axis("id", axis="columns") | ||
id name legs | ||
0 dog 4 | ||
1 cat 4 | ||
2 monkey 2 | ||
dog 4 0 | ||
cat 4 0 | ||
monkey 2 2 | ||
>>> df.rename_axis("limbs", axis="columns") | ||
limbs num_legs num_arms | ||
dog 4 0 | ||
cat 4 0 | ||
monkey 2 2 | ||
""" | ||
inplace = validate_bool_kwarg(inplace, 'inplace') | ||
non_mapper = is_scalar(mapper) or (is_list_like(mapper) and not | ||
|
@@ -1225,18 +1227,20 @@ def _set_axis_name(self, name, axis=0, inplace=False): | |
|
||
Examples | ||
-------- | ||
>>> df = pd.DataFrame({"legs": [4, 4, 2]}) | ||
legs | ||
0 4 | ||
1 4 | ||
2 2 | ||
>>> df = pd.DataFrame({"num_legs": [4, 4, 2]}, | ||
... ["dog", "cat", "monkey"]) | ||
num_legs | ||
dog 4 | ||
cat 4 | ||
monkey 2 | ||
>>> df._set_axis_name("animal") | ||
legs | ||
num_legs | ||
animal | ||
0 4 | ||
1 2 | ||
2 0 | ||
>>> df.index = pd.MultiIndex.from_product([["mammal"], ['dog', 'cat', 'monkey']]) | ||
dog 4 | ||
cat 4 | ||
monkey 2 | ||
>>> df.index = pd.MultiIndex.from_product( | ||
... [["mammal"], ['dog', 'cat', 'monkey']]) | ||
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. can you try to present this using a better indentation. I think this is not pep8 compatible |
||
>>> df._set_axis_name(["type", "name"]) | ||
legs | ||
type name | ||
|
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.
the indentation of this line looks wrong