w3resource

Pandas DataFrame: reindex_like() function

DataFrame - reindex_like() function

The reindex_like() function is used to return an object with matching indices as other object.

Syntax:

DataFrame.reindex_like(self, other, method=None, copy=True, limit=None, tolerance=None)

Parameters:

Name Description Type/Default Value Required / Optional
other                       Its row and column indices are used to define the new indices of this object. Object of the same data type Required
method  Method to use for filling holes in reindexed DataFrame. Please note: this is only applicable to DataFrames/Series with a monotonically increasing/decreasing index.
  • None (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
{None, ‘backfill’/’bfill’, ‘pad’/’ffill’, ‘nearest’} Required
copy   Return a new object, even if the passed indexes are the same. bool
Default Value: True
Required
limit   Maximum number of consecutive labels to fill for inexact matches. int
Default Value: None
Required
tolerance   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.
  Optional

Returns: Series or DataFrame
Same type as caller, but with changed indices on each axis.

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - last() function
Next: DataFrame - rename() function



Follow us on Facebook and Twitter for latest update.