- API reference
- Series
- pandas.Series.update
pandas.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. Alignson index.
- Parameters:
- otherSeries, or object coercible into Series
Examples
>>>s=pd.Series([1,2,3])>>>s.update(pd.Series([4,5,6]))>>>s0 41 52 6dtype: int64
>>>s=pd.Series(['a','b','c'])>>>s.update(pd.Series(['d','e'],index=[0,2]))>>>s0 d1 b2 edtype: object
>>>s=pd.Series([1,2,3])>>>s.update(pd.Series([4,5,6,7,8]))>>>s0 41 52 6dtype: int64
If
othercontains NaNs the corresponding values are not updatedin the original Series.>>>s=pd.Series([1,2,3])>>>s.update(pd.Series([4,np.nan,6]))>>>s0 41 22 6dtype: int64
othercan also be a non-Series object typethat is coercible into a Series>>>s=pd.Series([1,2,3])>>>s.update([4,np.nan,6])>>>s0 41 22 6dtype: int64
>>>s=pd.Series([1,2,3])>>>s.update({1:9})>>>s0 11 92 3dtype: int64
On this page