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

Method reindex

pandas/core/frame.py:5857–6103  ·  view source on GitHub ↗

Conform 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

5855 return super().set_axis(labels, axis=axis, copy=copy)
5856
5857 def reindex(
5858 self,
5859 labels=None,
5860 *,
5861 index=None,
5862 columns=None,
5863 axis: Axis | None = None,
5864 method: ReindexMethod | None = None,
5865 copy: bool | lib.NoDefault = lib.no_default,
5866 level: Level | None = None,
5867 fill_value: Scalar | None = np.nan,
5868 limit: int | None = None,
5869 tolerance=None,
5870 ) -> DataFrame:
5871 """
5872 Conform DataFrame to new index with optional filling logic.
5873
5874 Places NA/NaN in locations having no value in the previous index. A new object
5875 is produced unless the new index is equivalent to the current one and
5876 ``copy=False``.
5877
5878 Parameters
5879 ----------
5880
5881 labels : array-like, optional
5882 New labels / index to conform the axis specified by 'axis' to.
5883 index : array-like, optional
5884 New labels for the index. Preferably an Index object to avoid
5885 duplicating data.
5886 columns : array-like, optional
5887 New labels for the columns. Preferably an Index object to avoid
5888 duplicating data.
5889 axis : int or str, optional
5890 Axis to target. Can be either the axis name ('index', 'columns')
5891 or number (0, 1).
5892 method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}
5893 Method to use for filling holes in reindexed DataFrame.
5894 Please note: this is only applicable to DataFrames/Series with a
5895 monotonically increasing/decreasing index.
5896
5897 * None (default): don't fill gaps
5898 * pad / ffill: Propagate last valid observation forward to next
5899 valid.
5900 * backfill / bfill: Use next valid observation to fill gap.
5901 * nearest: Use nearest valid observations to fill gap.
5902
5903 copy : bool, default False
5904 This keyword is now ignored; changing its value will have no
5905 impact on the method.
5906
5907 .. deprecated:: 3.0.0
5908
5909 This keyword is ignored and will be removed in pandas 4.0. Since
5910 pandas 3.0, this method always returns a new object using a lazy
5911 copy mechanism that defers copies until necessary
5912 (Copy-on-Write). See the `user guide on Copy-on-Write
5913 <https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html>`__
5914 for more details.

Calls

no outgoing calls