pyspark.pandas.Series.reindex_like¶
-
Series.
reindex_like
(other: Union[Series, DataFrame]) → pyspark.pandas.series.Series¶ Return a Series with matching indices as other object.
Conform the object to the same index on all axes. Places NA/NaN in locations having no value in the previous index.
- Parameters
- otherSeries or DataFrame
Its row and column indices are used to define the new indices of this object.
- Returns
- Series
Series with changed indices on each axis.
See also
DataFrame.set_index
Set row labels.
DataFrame.reset_index
Remove row labels or move them to new columns.
DataFrame.reindex
Change to new indices or expand indices.
Notes
Same as calling
.reindex(index=other.index, ...)
.Examples
>>> s1 = ps.Series([24.3, 31.0, 22.0, 35.0], ... index=pd.date_range(start='2014-02-12', ... end='2014-02-15', freq='D'), ... name="temp_celsius") >>> s1 2014-02-12 24.3 2014-02-13 31.0 2014-02-14 22.0 2014-02-15 35.0 Name: temp_celsius, dtype: float64
>>> s2 = ps.Series(["low", "low", "medium"], ... index=pd.DatetimeIndex(['2014-02-12', '2014-02-13', ... '2014-02-15']), ... name="winspeed") >>> s2 2014-02-12 low 2014-02-13 low 2014-02-15 medium Name: winspeed, dtype: object
>>> s2.reindex_like(s1).sort_index() 2014-02-12 low 2014-02-13 low 2014-02-14 None 2014-02-15 medium Name: winspeed, dtype: object