Skip to content

Commit a102b0c

Browse files
eahoguejorisvandenbossche
authored andcommitted
DOC: Corrects 'reindex_axis' docstring (#24105)
1 parent defa8a8 commit a102b0c

File tree

1 file changed

+36
-26
lines changed

1 file changed

+36
-26
lines changed

pandas/core/generic.py

+36-26
Original file line numberDiff line numberDiff line change
@@ -4359,49 +4359,49 @@ def _reindex_multi(self, axes, copy, fill_value):
43594359
return NotImplemented
43604360

43614361
_shared_docs['reindex_axis'] = ("""
4362-
Conform input object to new index
4363-
with optional filling logic, placing NA/NaN in locations having
4364-
no value in the previous index. A new object is produced unless
4365-
the new index is equivalent to the current one and copy=False.
4362+
Conform input object to new index.
4363+
4364+
.. deprecated:: 0.21.0
4365+
Use `reindex` instead.
4366+
4367+
By default, places NaN in locations having no value in the
4368+
previous index. A new object is produced unless the new index
4369+
is equivalent to the current one and copy=False.
43664370
43674371
Parameters
43684372
----------
43694373
labels : array-like
43704374
New labels / index to conform to. Preferably an Index object to
4371-
avoid duplicating data
4375+
avoid duplicating data.
43724376
axis : %(axes_single_arg)s
4377+
Indicate whether to use rows or columns.
43734378
method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}, optional
43744379
Method to use for filling holes in reindexed DataFrame:
43754380
4376-
* default: don't fill gaps
4381+
* default: don't fill gaps.
43774382
* pad / ffill: propagate last valid observation forward to next
4378-
valid
4379-
* backfill / bfill: use next valid observation to fill gap
4380-
* nearest: use nearest valid observations to fill gap
4383+
valid.
4384+
* backfill / bfill: use next valid observation to fill gap.
4385+
* nearest: use nearest valid observations to fill gap.
43814386
4382-
copy : boolean, default True
4383-
Return a new object, even if the passed indexes are the same
4384-
level : int or name
4387+
level : int or str
43854388
Broadcast across a level, matching Index values on the
4386-
passed MultiIndex level
4387-
limit : int, default None
4388-
Maximum number of consecutive elements to forward or backward fill
4389-
tolerance : optional
4390-
Maximum distance between original and new labels for inexact
4391-
matches. The values of the index at the matching locations most
4392-
satisfy the equation ``abs(index[indexer] - target) <= tolerance``.
4393-
4394-
Tolerance may be a scalar value, which applies the same tolerance
4395-
to all values, or list-like, which applies variable tolerance per
4396-
element. List-like includes list, tuple, array, Series, and must be
4397-
the same size as the index and its dtype must exactly match the
4398-
index's type.
4389+
passed MultiIndex level.
4390+
copy : bool, default True
4391+
Return a new object, even if the passed indexes are the same.
4392+
limit : int, optional
4393+
Maximum number of consecutive elements to forward or backward fill.
4394+
fill_value : float, default NaN
4395+
Value used to fill in locations having no value in the previous
4396+
index.
43994397
44004398
.. versionadded:: 0.21.0 (list-like tolerance)
44014399
44024400
Returns
44034401
-------
44044402
%(klass)s
4403+
Returns a new DataFrame object with new indices, unless the new
4404+
index is equivalent to the current one and copy=False.
44054405
44064406
See Also
44074407
--------
@@ -4412,7 +4412,17 @@ def _reindex_multi(self, axes, copy, fill_value):
44124412
44134413
Examples
44144414
--------
4415-
>>> df.reindex_axis(['A', 'B', 'C'], axis=1)
4415+
>>> df = pd.DataFrame({'num_legs': [4, 2], 'num_wings': [0, 2]},
4416+
... index=['dog', 'hawk'])
4417+
>>> df
4418+
num_legs num_wings
4419+
dog 4 0
4420+
hawk 2 2
4421+
>>> df.reindex_axis(['num_wings', 'num_legs', 'num_heads'],
4422+
... axis='columns')
4423+
num_wings num_legs num_heads
4424+
dog 0 4 NaN
4425+
hawk 2 2 NaN
44164426
""")
44174427

44184428
@Appender(_shared_docs['reindex_axis'] % _shared_doc_kwargs)

0 commit comments

Comments
 (0)