pandas.Series.str.islower#

Series.str.islower()[源代码]#

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

这等效于运行Python字符串方法 str.islower() 对于系列/索引中的每个元素。如果字符串没有字符, 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

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

示例

检查字母和数字字符

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

请注意,对与任何其他标点符号或空格混合的字符进行检查时,字母数字检查的计算结果将为FALSE。

>>> s2 = pd.Series(['A B', '1.5', '3,000'])
>>> s2.str.isalnum()
0    False
1    False
2    False
dtype: bool

对数字字符进行更详细的检查

可以检查几组不同但重叠的数字字符集。

>>> s3 = pd.Series(['23', '³', '⅕', ''])

这个 s3.str.isdecimal 方法检查用于构成以10为基数的数字的字符。

>>> s3.str.isdecimal()
0     True
1    False
2    False
3    False
dtype: bool

这个 s.str.isdigit 方法与 s3.str.isdecimal 但也包括特殊数字,如Unicode中的上标和下标数字。

>>> s3.str.isdigit()
0     True
1     True
2    False
3    False
dtype: bool

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

>>> s3.str.isnumeric()
0     True
1     True
2     True
3    False
dtype: bool

检查是否有空格

>>> s4 = pd.Series([' ', '\t\r\n ', ''])
>>> s4.str.isspace()
0     True
1     True
2    False
dtype: bool

检查字符大小写

>>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])
>>> s5.str.islower()
0     True
1    False
2    False
3    False
dtype: bool
>>> s5.str.isupper()
0    False
1    False
2     True
3    False
dtype: bool

这个 s5.str.istitle 方法检查是否所有单词都是标题大小写(是否只有每个单词的第一个字母大写)。假设单词是由空格字符分隔的任何非数字字符序列。

>>> s5.str.istitle()
0    False
1     True
2    False
3    False
dtype: bool