-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
DOC: Corrects 'reindex_axis' docstring #24105
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
Changes from 4 commits
34e5fc6
1208e50
ffbad45
b54ea1d
43f73dd
dacc3d3
5b46081
d610339
c11052d
963a31d
0a8456c
822dca1
201ef53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4311,60 +4311,63 @@ def _needs_reindex_multi(self, axes, method, level): | |
def _reindex_multi(self, axes, copy, fill_value): | ||
return NotImplemented | ||
|
||
_shared_docs['reindex_axis'] = ("""Conform input object to new index | ||
with optional filling logic, placing NA/NaN in locations having | ||
no value in the previous index. A new object is produced unless | ||
the new index is equivalent to the current one and copy=False. | ||
_shared_docs['reindex_axis'] = (""" | ||
Conform input object to new index. | ||
|
||
By default, places NA/NaN in locations having no value in the | ||
previous index. A new object is produced unless the new index | ||
is equivalent to the current one and copy=False. | ||
|
||
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.
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, I have added this to the end of the summary. Based on other docstrings it looks like that's the place to put it. 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. Yes, that looks good! |
||
Parameters | ||
---------- | ||
labels : array-like | ||
New labels / index to conform to. Preferably an Index object to | ||
avoid duplicating data | ||
avoid duplicating data. | ||
axis : %(axes_single_arg)s | ||
Indicate whether to use rows or columns. | ||
method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}, optional | ||
Method to use for filling holes in reindexed DataFrame: | ||
|
||
* default: don't fill gaps | ||
* default: don't fill gaps. | ||
* pad / ffill: propagate last valid observation forward to next | ||
valid | ||
* backfill / bfill: use next valid observation to fill gap | ||
* nearest: use nearest valid observations to fill gap | ||
valid. | ||
* backfill / bfill: use next valid observation to fill gap. | ||
* nearest: use nearest valid observations to fill gap. | ||
|
||
copy : boolean, default True | ||
Return a new object, even if the passed indexes are the same | ||
level : int or name | ||
eahogue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Broadcast across a level, matching Index values on the | ||
passed MultiIndex level | ||
passed MultiIndex level. | ||
copy : bool, default True | ||
Return a new object, even if the passed indexes are the same. | ||
limit : int, default None | ||
eahogue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Maximum number of consecutive elements to forward or backward fill | ||
tolerance : optional | ||
Maximum distance between original and new labels for inexact | ||
matches. The values of the index at the matching locations most | ||
satisfy the equation ``abs(index[indexer] - target) <= tolerance``. | ||
|
||
Tolerance may be a scalar value, which applies the same tolerance | ||
to all values, or list-like, which applies variable tolerance per | ||
element. List-like includes list, tuple, array, Series, and must be | ||
the same size as the index and its dtype must exactly match the | ||
index's type. | ||
Maximum number of consecutive elements to forward or backward fill. | ||
fill_value : float, default NaN | ||
Value used to fill in locations having no value in the previous | ||
index. | ||
|
||
.. versionadded:: 0.21.0 (list-like tolerance) | ||
|
||
Returns | ||
------- | ||
%(klass)s | ||
eahogue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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. | ||
|
||
Returns | ||
------- | ||
%(klass)s | ||
|
||
Examples | ||
-------- | ||
>>> df.reindex_axis(['A', 'B', 'C'], axis=1) | ||
>>> df = pd.DataFrame(np.array(([1,2,3], [4,5,6], [7,8,9])), | ||
eahogue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
... index=['One', 'Two', 'Three'], | ||
... columns=['A', 'B', 'C']) | ||
eahogue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
>>> df.reindex_axis(['B', 'C', 'D'], axis=1) | ||
eahogue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
B C D | ||
One 2 3 NaN | ||
Two 5 6 NaN | ||
Three 8 9 NaN | ||
eahogue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""") | ||
|
||
@Appender(_shared_docs['reindex_axis'] % _shared_doc_kwargs) | ||
|
Uh oh!
There was an error while loading. Please reload this page.