Conform Series 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 ----------
( # type: ignore[override]
self,
index=None,
*,
axis: Axis | None = None,
method: ReindexMethod | None = None,
copy: bool | lib.NoDefault = lib.no_default,
level: Level | None = None,
fill_value: Scalar | None = None,
limit: int | None = None,
tolerance=None,
)
| 5297 | # error: Cannot determine type of 'reindex' |
| 5298 | |
| 5299 | def reindex( # type: ignore[override] |
| 5300 | self, |
| 5301 | index=None, |
| 5302 | *, |
| 5303 | axis: Axis | None = None, |
| 5304 | method: ReindexMethod | None = None, |
| 5305 | copy: bool | lib.NoDefault = lib.no_default, |
| 5306 | level: Level | None = None, |
| 5307 | fill_value: Scalar | None = None, |
| 5308 | limit: int | None = None, |
| 5309 | tolerance=None, |
| 5310 | ) -> Series: |
| 5311 | """ |
| 5312 | Conform Series to new index with optional filling logic. |
| 5313 | |
| 5314 | Places NA/NaN in locations having no value in the previous index. A new object |
| 5315 | is produced unless the new index is equivalent to the current one and |
| 5316 | ``copy=False``. |
| 5317 | |
| 5318 | Parameters |
| 5319 | ---------- |
| 5320 | index : scalar, list-like, dict-like or function, optional |
| 5321 | A scalar, list-like, dict-like or functions transformations to |
| 5322 | apply to that axis' values. |
| 5323 | axis : {0 or 'index'}, default 0 |
| 5324 | The axis to rename. For `Series` this parameter is unused and defaults to 0. |
| 5325 | method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'} |
| 5326 | Method to use for filling holes in reindexed DataFrame. |
| 5327 | Please note: this is only applicable to DataFrames/Series with a |
| 5328 | monotonically increasing/decreasing index. |
| 5329 | |
| 5330 | * None (default): don't fill gaps |
| 5331 | * pad / ffill: Propagate last valid observation forward to next |
| 5332 | valid. |
| 5333 | * backfill / bfill: Use next valid observation to fill gap. |
| 5334 | * nearest: Use nearest valid observations to fill gap. |
| 5335 | |
| 5336 | copy : bool, default False |
| 5337 | This keyword is now ignored; changing its value will have no |
| 5338 | impact on the method. |
| 5339 | |
| 5340 | .. deprecated:: 3.0.0 |
| 5341 | |
| 5342 | This keyword is ignored and will be removed in pandas 4.0. Since |
| 5343 | pandas 3.0, this method always returns a new object using a lazy |
| 5344 | copy mechanism that defers copies until necessary |
| 5345 | (Copy-on-Write). See the `user guide on Copy-on-Write |
| 5346 | <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__ |
| 5347 | for more details. |
| 5348 | |
| 5349 | level : int or name |
| 5350 | Broadcast across a level, matching Index values on the |
| 5351 | passed MultiIndex level. |
| 5352 | fill_value : scalar, default np.nan |
| 5353 | Value to use for missing values. Defaults to NaN, but can be any |
| 5354 | "compatible" value. |
| 5355 | limit : int, default None |
| 5356 | Maximum number of consecutive elements to forward or backward fill. |
no outgoing calls