-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
DOC: update the DataFrame.reindex_like docstring #22775
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
WillAyd
merged 19 commits into
pandas-dev:master
from
math-and-data:docstring_reindex_like
Nov 26, 2018
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bab3a2b
DOC: Improve the docstring of DataFrame.reindex_like()
math-and-data cd3ec62
DOC: Improve the docstring of DataFrame.reindex_like()
math-and-data 1ee2751
DOC: Improve the docstring of DataFrame.reindex_like()
math-and-data 2cbf5dd
docstring for .reindex_like
math-and-data 92c1d2f
docstring .reindex_like: input params details
math-and-data 5bcee6d
docstring .reset_index, .set_index, .reindex, .reindex_like
math-and-data 2729193
docstring set_index: PEP8 style check
math-and-data 4851b91
Merge branch 'master' into docstring_reindex_like
math-and-data be1a774
reindex: formatting
math-and-data 7072e4a
reindex: formatting of docstring
math-and-data 88e6e37
Update pandas/core/generic.py
datapythonista 38c5c94
Update pandas/core/generic.py
datapythonista 4518791
reindex_like print example df
math-and-data 9d58d4e
Merge branch 'docstring_reindex_like' of https://github.com/math-and-…
math-and-data 363e8c0
reindex_like params
math-and-data 4d59844
reindex docstring: pep8 line length
math-and-data 6bf4977
Addressing code review comments
datapythonista 2a838f2
Merge remote-tracking branch 'upstream/master' into docstring_reindex…
datapythonista 7df1f79
Addressing review comments
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
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 |
---|---|---|
|
@@ -3926,22 +3926,36 @@ def shift(self, periods=1, freq=None, axis=0): | |
def set_index(self, keys, drop=True, append=False, inplace=False, | ||
verify_integrity=False): | ||
""" | ||
Set the DataFrame index using existing columns. | ||
|
||
Set the DataFrame index (row labels) using one or more existing | ||
columns. By default yields a new object. | ||
columns. The index can replace the existing index or expand on it. | ||
|
||
Parameters | ||
---------- | ||
keys : column label or list of column labels / arrays | ||
drop : boolean, default True | ||
Delete columns to be used as the new index | ||
append : boolean, default False | ||
Whether to append columns to existing index | ||
inplace : boolean, default False | ||
Modify the DataFrame in place (do not create a new object) | ||
verify_integrity : boolean, default False | ||
keys : label or list of label | ||
Name or names of the columns that will be used as the index. | ||
drop : bool, default True | ||
Delete columns to be used as the new index. | ||
append : bool, default False | ||
Whether to append columns to existing index. | ||
inplace : bool, default False | ||
Modify the DataFrame in place (do not create a new object). | ||
verify_integrity : bool, default False | ||
Check the new index for duplicates. Otherwise defer the check until | ||
necessary. Setting to False will improve the performance of this | ||
method | ||
method. | ||
|
||
Returns | ||
------- | ||
DataFrame | ||
Changed row labels. | ||
|
||
See Also | ||
-------- | ||
DataFrame.reset_index : Opposite of set_index. | ||
DataFrame.reindex : Change to new indices or expand indices. | ||
DataFrame.reindex_like : Change to same indices as other DataFrame. | ||
|
||
Returns | ||
------- | ||
|
@@ -3951,22 +3965,23 @@ def set_index(self, keys, drop=True, append=False, inplace=False, | |
-------- | ||
>>> df = pd.DataFrame({'month': [1, 4, 7, 10], | ||
... 'year': [2012, 2014, 2013, 2014], | ||
... 'sale':[55, 40, 84, 31]}) | ||
month sale year | ||
0 1 55 2012 | ||
1 4 40 2014 | ||
2 7 84 2013 | ||
3 10 31 2014 | ||
... 'sale': [55, 40, 84, 31]}) | ||
>>> df | ||
month year sale | ||
0 1 2012 55 | ||
1 4 2014 40 | ||
2 7 2013 84 | ||
3 10 2014 31 | ||
|
||
Set the index to become the 'month' column: | ||
|
||
>>> df.set_index('month') | ||
sale year | ||
year sale | ||
month | ||
1 55 2012 | ||
4 40 2014 | ||
7 84 2013 | ||
10 31 2014 | ||
1 2012 55 | ||
4 2014 40 | ||
7 2013 84 | ||
10 2014 31 | ||
|
||
Create a multi-index using columns 'year' and 'month': | ||
|
||
|
@@ -4074,22 +4089,22 @@ def set_index(self, keys, drop=True, append=False, inplace=False, | |
def reset_index(self, level=None, drop=False, inplace=False, col_level=0, | ||
col_fill=''): | ||
""" | ||
For DataFrame with multi-level index, return new DataFrame with | ||
labeling information in the columns under the index names, defaulting | ||
to 'level_0', 'level_1', etc. if any are None. For a standard index, | ||
the index name will be used (if set), otherwise a default 'index' or | ||
'level_0' (if 'index' is already taken) will be used. | ||
Reset the index, or a level of it. | ||
|
||
Reset the index of the DataFrame, and use the default one instead. | ||
If the DataFrame has a MultiIndex, this method can remove one or more | ||
of them. | ||
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. I think |
||
|
||
Parameters | ||
---------- | ||
level : int, str, tuple, or list, default None | ||
Only remove the given levels from the index. Removes all levels by | ||
default | ||
drop : boolean, default False | ||
default. | ||
drop : bool, default False | ||
Do not try to insert index into dataframe columns. This resets | ||
the index to the default integer index. | ||
inplace : boolean, default False | ||
Modify the DataFrame in place (do not create a new object) | ||
inplace : bool, default False | ||
Modify the DataFrame in place (do not create a new object). | ||
col_level : int or str, default 0 | ||
If the columns have multiple levels, determines which level the | ||
labels are inserted into. By default it is inserted into the first | ||
|
@@ -4100,13 +4115,20 @@ def reset_index(self, level=None, drop=False, inplace=False, col_level=0, | |
|
||
Returns | ||
------- | ||
resetted : DataFrame | ||
DataFrame | ||
DataFrame with the new index. | ||
|
||
See Also | ||
-------- | ||
DataFrame.set_index : Opposite of reset_index. | ||
DataFrame.reindex : Change to new indices or expand indices. | ||
DataFrame.reindex_like : Change to same indices as other DataFrame. | ||
|
||
Examples | ||
-------- | ||
>>> df = pd.DataFrame([('bird', 389.0), | ||
... ('bird', 24.0), | ||
... ('mammal', 80.5), | ||
>>> df = pd.DataFrame([('bird', 389.0), | ||
... ('bird', 24.0), | ||
... ('mammal', 80.5), | ||
... ('mammal', np.nan)], | ||
... index=['falcon', 'parrot', 'lion', 'monkey'], | ||
... columns=('class', 'max_speed')) | ||
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.