Modify Series in place using values from passed Series. Uses non-NA values from passed Series to make updates. Aligns on index. Parameters ---------- other : Series, or object coercible into Series Other Series that provides values to up
(self, other: Series | Sequence | Mapping)
| 3443 | return combined.__finalize__(self, method="combine_first") |
| 3444 | |
| 3445 | def update(self, other: Series | Sequence | Mapping) -> None: |
| 3446 | """ |
| 3447 | Modify Series in place using values from passed Series. |
| 3448 | |
| 3449 | Uses non-NA values from passed Series to make updates. Aligns |
| 3450 | on index. |
| 3451 | |
| 3452 | Parameters |
| 3453 | ---------- |
| 3454 | other : Series, or object coercible into Series |
| 3455 | Other Series that provides values to update the current Series. |
| 3456 | |
| 3457 | See Also |
| 3458 | -------- |
| 3459 | Series.combine : Perform element-wise operation on two Series |
| 3460 | using a given function. |
| 3461 | Series.transform: Modify a Series using a function. |
| 3462 | |
| 3463 | Examples |
| 3464 | -------- |
| 3465 | >>> s = pd.Series([1, 2, 3]) |
| 3466 | >>> s.update(pd.Series([4, 5, 6])) |
| 3467 | >>> s |
| 3468 | 0 4 |
| 3469 | 1 5 |
| 3470 | 2 6 |
| 3471 | dtype: int64 |
| 3472 | |
| 3473 | >>> s = pd.Series(["a", "b", "c"]) |
| 3474 | >>> s.update(pd.Series(["d", "e"], index=[0, 2])) |
| 3475 | >>> s |
| 3476 | 0 d |
| 3477 | 1 b |
| 3478 | 2 e |
| 3479 | dtype: str |
| 3480 | |
| 3481 | >>> s = pd.Series([1, 2, 3]) |
| 3482 | >>> s.update(pd.Series([4, 5, 6, 7, 8])) |
| 3483 | >>> s |
| 3484 | 0 4 |
| 3485 | 1 5 |
| 3486 | 2 6 |
| 3487 | dtype: int64 |
| 3488 | |
| 3489 | If ``other`` contains NaNs the corresponding values are not updated |
| 3490 | in the original Series. |
| 3491 | |
| 3492 | >>> s = pd.Series([1, 2, 3]) |
| 3493 | >>> s.update(pd.Series([4, np.nan, 6])) |
| 3494 | >>> s |
| 3495 | 0 4 |
| 3496 | 1 2 |
| 3497 | 2 6 |
| 3498 | dtype: int64 |
| 3499 | |
| 3500 | ``other`` can also be a non-Series object type |
| 3501 | that is coercible into a Series |
| 3502 |