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


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


用法:

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

获取数据帧或系列和其他元素的浮点数除法(二元运算符rtruediv)。

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

参数

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
           angles  degrees
circle          0      360
triangle        3      180
rectangle       4      360
>>> df.rtruediv(10)
             angles   degrees
circle          inf  0.027778
triangle   3.333333  0.055556
rectangle  2.500000  0.027778
>>> df.rdiv(10)
             angles   degrees
circle          inf  0.027778
triangle   3.333333  0.055556
rectangle  2.500000  0.027778
>>> 10 / df
             angles   degrees
circle          inf  0.027778
triangle   3.333333  0.055556
rectangle  2.500000  0.027778

Series

>>> import cudf
>>> a = cudf.Series([10, 20, None, 30], index=['a', 'b', 'c', 'd'])
>>> a
a      10
b      20
c    <NA>
d      30
dtype: int64
>>> b = cudf.Series([1, None, 2, 3], index=['a', 'b', 'd', 'e'])
>>> b
a       1
b    <NA>
d       2
e       3
dtype: int64
>>> a.rtruediv(b, fill_value=0)
a            0.1
b            0.0
c           <NA>
d    0.066666667
e            Inf
dtype: float64

相关用法


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