8000 DOC: update the DataFrame.reindex_like docstring by math-and-data · Pull Request #22775 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

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
merged 19 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressing code review comments
  • Loading branch information
datapythonista committed Nov 21, 2018
commit 6bf4977335b62b10e256286d23fd224e461fe497
25 changes: 11 additions & 14 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3909,16 +3909,15 @@ def shift(self, periods=1, freq=None, axis=0):
def set_index(self, keys, drop=True, append=False, inplace=False,
verify_integrity=False):
"""
An index is created with existing columns.
Set the DataFrame index using existing columns.

Set the DataFrame index (row labels) using one or more existing
columns. The index can replace the existing index or expand on it.

Parameters
----------
keys : str or list of str or array
Column label or list of column labels / arrays that will
form the new index.
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
Expand Down Expand Up @@ -4049,13 +4048,11 @@ 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=''):
"""
An existing index is modified.
Reset the index, or a level of it.

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 of the DataFrame, and use the default one instead.
If the DataFrame has a MultiIndex, this method can remove one or more
of them.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think levels would be clearer than of them


Parameters
----------
Expand All @@ -4078,7 +4075,7 @@ def reset_index(self, level=None, drop=False, inplace=False, col_level=0,
Returns
-------
DataFrame
Changed row labels.
DataFrame with the new index.

See Also
--------
Expand All @@ -4088,9 +4085,9 @@ def reset_index(self, level=None, drop=False, inplace=False, col_level=0,

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'))
Expand Down
13 changes: 7 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3359,7 +3359,8 @@ def reindex_like(self, other, method=None, copy=True, limit=None,

Notes
-----
Like calling ``.reindex(index=other.index,columns=other.columns,...)``.
Same as calling
``.reindex(index=other.index, columns=other.columns,...)``.

Returns
-------
Expand Down Expand Up @@ -4083,14 +4084,14 @@ def _reindex_multi(self, axes, copy, fill_value):

See Also
--------
DataFrame.set_index : set row labels
DataFrame.reset_index : remove row labels or move them to new columns
DataFrame.reindex : change to new indices or expand indices
DataFrame.reindex_like : change to same indices as other DataFrame
DataFrame.set_index : Set row labels.
DataFrame.reset_index : Remove row labels or move them to new columns.
DataFrame.reindex : Change to new indices or expand indices.
DataFrame.reindex_like : Change to same indices as other DataFrame.

Returns
-------
reindexed : %(klass)s
%(klass)s

Examples
--------
Expand Down
0