cudf.Series.update#

Series.update(other)[source]#

Modify Series in place using values from passed Series. Uses non-NA values from passed Series to make updates. Aligns on index.

Parameters:
otherSeries, or object coercible into Series

Examples

>>> import cudf
>>> s = cudf.Series([1, 2, 3])
>>> s
0    1
1    2
2    3
dtype: int64
>>> s.update(cudf.Series([4, 5, 6]))
>>> s
0    4
1    5
2    6
dtype: int64
>>> s = cudf.Series(['a', 'b', 'c'])
>>> s
0    a
1    b
2    c
dtype: object
>>> s.update(cudf.Series(['d', 'e'], index=[0, 2]))
>>> s
0    d
1    b
2    e
dtype: object
>>> s = cudf.Series([1, 2, 3])
>>> s
0    1
1    2
2    3
dtype: int64
>>> s.update(cudf.Series([4, 5, 6, 7, 8]))
>>> s
0    4
1    5
2    6
dtype: int64

If other contains NaNs the corresponding values are not updated in the original Series.

>>> s = cudf.Series([1.0, 2.0, 3.0])
>>> s
0    1.0
1    2.0
2    3.0
dtype: float64
>>> s.update(cudf.Series([4.0, np.nan, 6.0], nan_as_null=False))
>>> s
0    4.0
1    2.0
2    6.0
dtype: float64

other can also be a non-Series object type that is coercible into a Series

>>> s = cudf.Series([1, 2, 3])
>>> s
0    1
1    2
2    3
dtype: int64
>>> s.update([4, np.nan, 6])
>>> s
0    4
1    2
2    6
dtype: int64
>>> s = cudf.Series([1, 2, 3])
>>> s
0    1
1    2
2    3
dtype: int64
>>> s.update({1: 9})
>>> s
0    1
1    9
2    3
dtype: int64