pyspark.pandas.Series.update#
- Series.update(other)[source]#
Modify Series in place using non-NA values from passed Series. Aligns on index.
- Parameters
- otherSeries
Examples
>>> from pyspark.pandas.config import set_option, reset_option >>> set_option("compute.ops_on_diff_frames", True) >>> s = ps.Series([1, 2, 3]) >>> s.update(ps.Series([4, 5, 6])) >>> s.sort_index() 0 4 1 5 2 6 dtype: int64
>>> s = ps.Series(['a', 'b', 'c']) >>> s.update(ps.Series(['d', 'e'], index=[0, 2])) >>> s.sort_index() 0 d 1 b 2 e dtype: object
>>> s = ps.Series([1, 2, 3]) >>> s.update(ps.Series([4, 5, 6, 7, 8])) >>> s.sort_index() 0 4 1 5 2 6 dtype: int64
>>> s = ps.Series([1, 2, 3], index=[10, 11, 12]) >>> s 10 1 11 2 12 3 dtype: int64
>>> s.update(ps.Series([4, 5, 6])) >>> s.sort_index() 10 1 11 2 12 3 dtype: int64
>>> s.update(ps.Series([4, 5, 6], index=[11, 12, 13])) >>> s.sort_index() 10 1 11 4 12 5 dtype: int64
If
other
contains NaNs the corresponding values are not updated in the original Series.>>> s = ps.Series([1, 2, 3]) >>> s.update(ps.Series([4, np.nan, 6])) >>> s.sort_index() 0 4.0 1 2.0 2 6.0 dtype: float64
>>> reset_option("compute.ops_on_diff_frames")