MCPcopy
hub / github.com/pandas-dev/pandas / reindex

Method reindex

pandas/core/generic.py:5189–5466  ·  view source on GitHub ↗

Conform Series/DataFrame to new index with optional filling logic. 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``. Parameters ------

(
        self,
        labels=None,
        *,
        index=None,
        columns=None,
        axis: Axis | None = None,
        method: ReindexMethod | None = None,
        copy: bool | lib.NoDefault = lib.no_default,
        level: Level | None = None,
        fill_value: Scalar | None = np.nan,
        limit: int | None = None,
        tolerance=None,
    )

Source from the content-addressed store, hash-verified

5187 return result.__finalize__(self, method="sort_index")
5188
5189 def reindex(
5190 self,
5191 labels=None,
5192 *,
5193 index=None,
5194 columns=None,
5195 axis: Axis | None = None,
5196 method: ReindexMethod | None = None,
5197 copy: bool | lib.NoDefault = lib.no_default,
5198 level: Level | None = None,
5199 fill_value: Scalar | None = np.nan,
5200 limit: int | None = None,
5201 tolerance=None,
5202 ) -> Self:
5203 """
5204 Conform Series/DataFrame to new index with optional filling logic.
5205
5206 Places NA/NaN in locations having no value in the previous index. A new object
5207 is produced unless the new index is equivalent to the current one and
5208 ``copy=False``.
5209
5210 Parameters
5211 ----------
5212 method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}
5213 Method to use for filling holes in reindexed DataFrame.
5214 Please note: this is only applicable to DataFrames/Series with a
5215 monotonically increasing/decreasing index.
5216
5217 * None (default): don't fill gaps
5218 * pad / ffill: Propagate last valid observation forward to next
5219 valid.
5220 * backfill / bfill: Use next valid observation to fill gap.
5221 * nearest: Use nearest valid observations to fill gap.
5222
5223 copy : bool, default False
5224 This keyword is now ignored; changing its value will have no
5225 impact on the method.
5226
5227 .. deprecated:: 3.0.0
5228
5229 This keyword is ignored and will be removed in pandas 4.0. Since
5230 pandas 3.0, this method always returns a new object using a lazy
5231 copy mechanism that defers copies until necessary
5232 (Copy-on-Write). See the `user guide on Copy-on-Write
5233 <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
5234 for more details.
5235
5236 level : int or name
5237 Broadcast across a level, matching Index values on the
5238 passed MultiIndex level.
5239 fill_value : scalar, default np.nan
5240 Value to use for missing values. Defaults to NaN, but can be any
5241 "compatible" value.
5242 limit : int, default None
5243 Maximum number of consecutive elements to forward or backward fill.
5244 tolerance : optional
5245 Maximum distance between original and new labels for inexact
5246 matches. The values of the index at the matching locations most

Callers 4

reindex_likeMethod · 0.95
filterMethod · 0.95
_reindex_axesMethod · 0.45
_whereMethod · 0.45

Calls 11

_get_axis_numberMethod · 0.95
_get_axisMethod · 0.95
copyMethod · 0.95
_needs_reindex_multiMethod · 0.95
_reindex_multiMethod · 0.95
_reindex_axesMethod · 0.95
identicalMethod · 0.80
__finalize__Method · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected