maxframe.dataframe.Series.update#
- Series.update(other)#
使用传入的 Series 中的值就地修改 Series。
使用传入的 Series 中的非 NA 值进行更新。按索引对齐。
- 参数:
other (Series, or object coercible into Series)
示例
>>> import maxframe.tensor as mt >>> import maxframe.dataframe as md >>> s = md.Series([1, 2, 3]) >>> s.update(md.Series([4, 5, 6])) >>> s.execute() 0 4 1 5 2 6 dtype: int64
>>> s = md.Series(['a', 'b', 'c']) >>> s.update(md.Series(['d', 'e'], index=[0, 2])) >>> s.execute() 0 d 1 b 2 e dtype: object
>>> s = md.Series([1, 2, 3]) >>> s.update(md.Series([4, 5, 6, 7, 8])) >>> s.execute() 0 4 1 5 2 6 dtype: int64
如果
other包含 NaN,则原始 Series 中对应的值不会被更新。>>> s = md.Series([1, 2, 3]) >>> s.update(md.Series([4, mt.nan, 6])) >>> s.execute() 0 4 1 2 2 6 dtype: int64
other也可以是可强制转换为 Series 的非 Series 对象类型>>> s = md.Series([1, 2, 3]) >>> s.update([4, mt.nan, 6]) >>> s.execute() 0 4 1 2 2 6 dtype: int64
>>> s = md.Series([1, 2, 3]) >>> s.update({1: 9}) >>> s.execute() 0 1 1 9 2 3 dtype: int64