当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python cudf.Series.radd用法及代码示例


用法:

Series.radd(other, level=None, fill_value=None, axis=0)

获取 DataFrame 或系列和其他元素的添加(二元运算符 radd )。

等效于 other + frame ,但支持用 fill_value 替换其中一个输入中的缺失数据。使用反向版本 add

参数

other标量、序列、系列或数据帧

任何单元素或多元素数据结构,或list-like 对象。

axis整数或字符串

系列仅支持0,数据帧支持1columns

fill_value浮点数或无,默认无

在计算之前使用此值填充现有的缺失 (NaN) 值以及成功对齐 DataFrame 所需的任何新元素。如果两个相应的 DataFrame 位置中的数据都丢失,则结果将丢失。

返回

DataFrame或Series

算术运算的结果。

例子

DataFrame

>>> import cudf
>>> df = cudf.DataFrame({'angles': [0, 3, 4],
...                    'degrees': [360, 180, 360]},
...                   index=['circle', 'triangle', 'rectangle'])
>>> df + 1
           angles  degrees
circle          1      361
triangle        4      181
rectangle       5      361
>>> df.radd(1)
           angles  degrees
circle          1      361
triangle        4      181
rectangle       5      361

Series

>>> a = cudf.Series([1, 2, 3, None], index=['a', 'b', 'c', 'd'])
>>> a
a       1
b       2
c       3
d    <NA>
dtype: int64
>>> b = cudf.Series([1, None, 1, None], index=['a', 'b', 'd', 'e'])
>>> b
a       1
b    <NA>
d       1
e    <NA>
dtype: int64
>>> a.add(b, fill_value=0)
a       2
b       2
c       3
d       1
e    <NA>
dtype: int64

相关用法


注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cudf.Series.radd。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。