mars.dataframe.Series.str.isalpha#
- Series.str.isalpha()#
检查每个字符串中的所有字符是否都是字母。
这相当于对Series/Index的每个元素运行Python字符串方法
str.isalpha()。如果一个字符串 包含零个字符,则该检查返回False。另请参阅
Series.str.isalpha检查所有字符是否为字母。
Series.str.isnumeric检查所有字符是否都是数字。
Series.str.isalnum检查所有字符是否都是字母数字字符。
Series.str.isdigit检查所有字符是否都是数字。
Series.str.isdecimal检查所有字符是否为十进制。
Series.str.isspace检查所有字符是否为空格。
Series.str.islower检查所有字符是否都是小写。
Series.str.isupper检查所有字符是否为大写。
Series.str.istitle检查所有字符是否为标题格式。
示例
检查字母和数字字符
>>> import mars.dataframe as md >>> s1 = md.Series(['one', 'one1', '1', ''])
>>> s1.str.isalpha().execute() 0 True 1 False 2 False 3 False dtype: bool
>>> s1.str.isnumeric().execute() 0 False 1 False 2 True 3 False dtype: bool
>>> s1.str.isalnum().execute() 0 True 1 True 2 True 3 False dtype: bool
请注意,混合任何额外标点符号或空白字符的字符在进行字母数字检查时将评估为假。
>>> s2 = md.Series(['A B', '1.5', '3,000']) >>> s2.str.isalnum().execute() 0 False 1 False 2 False dtype: bool
对数字字符进行更详细的检查
可以检查几组不同但重叠的数字字符。
>>> s3 = md.Series(['23', '³', '⅕', ''])
s3.str.isdecimal方法检查用来构成十进制数字的字符。>>> s3.str.isdecimal().execute() 0 True 1 False 2 False 3 False dtype: bool
s.str.isdigit方法与s3.str.isdecimal相同,但还包括特殊数字,例如Unicode中的上标和下标数字。>>> s3.str.isdigit().execute() 0 True 1 True 2 False 3 False dtype: bool
s.str.isnumeric方法与s3.str.isdigit相同,但还包括其他可以表示数量的字符,例如 unicode 分数。>>> s3.str.isnumeric().execute() 0 True 1 True 2 True 3 False dtype: bool
检查空白字符
>>> s4 = md.Series([' ', '\t\r\n ', '']) >>> s4.str.isspace().execute() 0 True 1 True 2 False dtype: bool
检查字符大小写
>>> s5 = md.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])
>>> s5.str.islower().execute() 0 True 1 False 2 False 3 False dtype: bool
>>> s5.str.isupper().execute() 0 False 1 False 2 True 3 False dtype: bool
s5.str.istitle方法检查所有单词是否为标题格式(即每个单词的首字母是否大写)。单词被认为是任何由空白字符分隔的非数字字符的序列。>>> s5.str.istitle().execute() 0 False 1 True 2 False 3 False dtype: bool