maxframe.dataframe.Series.str.isnumeric#

Series.str.isnumeric()#

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

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

返回:

与原始 Series/Index 长度相同的布尔值 Series 或 Index。

返回类型:

Series or Index of bool

参见

Series.str.isalpha

检查所有字符是否都是字母。

Series.str.isalnum

检查所有字符是否都是字母或数字。

Series.str.isdigit

检查所有字符是否都是数字。

Series.str.isdecimal

检查所有字符是否都是十进制数字。

Series.str.isspace

检查所有字符是否都是空白字符。

Series.str.islower

检查所有字符是否都是小写。

Series.str.isascii

Check whether all characters are ascii.

Series.str.isupper

检查所有字符是否都是大写。

Series.str.istitle

检查所有字符是否都是标题格式(首字母大写)。

示例

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

>>> import maxframe.dataframe as md
>>> s1 = md.Series(["one", "one1", "1", "", "³", "⅕"])
>>> s1.str.isnumeric().execute()
0    False
1    False
2     True
3    False
4     True
5     True
dtype: bool

For a string to be considered numeric, all its characters must have a Unicode numeric property matching str.is_numeric(). As a consequence, the following cases are not recognized as numeric:

  • Decimal numbers (e.g., "1.1"): due to period "."

  • Negative numbers (e.g., "-5"): due to minus sign "-"

  • Scientific notation (e.g., "1e3"): due to characters like "e"

>>> s2 = md.Series(["1.1", "-5", "1e3"])
>>> s2.str.isnumeric().execute()
0    False
1    False
2    False
dtype: bool