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


Python cudf.core.column.string.StringMethods.isnumeric用法及代码示例


用法:

StringMethods.isnumeric() → SeriesOrIndex

检查每个字符串中的所有字符是否都是数字。

这相当于为 Series/Index 的每个元素运行 Python 字符串方法str.isnumeric()。如果字符串有零个字符,则为该检查返回 False。

返回

布尔系列或索引

与原始系列/索引长度相同的布尔值系列或索引。

例子

>>> import cudf
>>> s1 = cudf.Series(['one', 'one1', '1', ''])
>>> s1.str.isnumeric()
0    False
1    False
2     True
3    False
dtype: bool

s1.str.isnumeric 方法与 s2.str.isdigit 相同,但还包括其他可以表示数量的字符,例如 unicode 分数。

>>> s2 = pd.Series(['23', '³', '⅕', ''])
>>> s2.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool

相关用法


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