Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Series.str.isalpha#

Series.str.isalpha()[source]#

Check whether all characters in each string are alphabetic.

This is equivalent to running the Python string methodstr.isalpha() for each element of the Series/Index. If a stringhas zero characters,False is returned for that check.

Returns:
Series or Index of bool

Series or Index of boolean values with the same length as the originalSeries/Index.

See also

Series.str.isalpha

Check whether all characters are alphabetic.

Series.str.isnumeric

Check whether all characters are numeric.

Series.str.isalnum

Check whether all characters are alphanumeric.

Series.str.isdigit

Check whether all characters are digits.

Series.str.isdecimal

Check whether all characters are decimal.

Series.str.isspace

Check whether all characters are whitespace.

Series.str.islower

Check whether all characters are lowercase.

Series.str.isupper

Check whether all characters are uppercase.

Series.str.istitle

Check whether all characters are titlecase.

Examples

Checks for Alphabetic and Numeric Characters

>>>s1=pd.Series(['one','one1','1',''])
>>>s1.str.isalpha()0     True1    False2    False3    Falsedtype: bool
>>>s1.str.isnumeric()0    False1    False2     True3    Falsedtype: bool
>>>s1.str.isalnum()0     True1     True2     True3    Falsedtype: bool

Note that checks against characters mixed with any additional punctuationor whitespace will evaluate to false for an alphanumeric check.

>>>s2=pd.Series(['A B','1.5','3,000'])>>>s2.str.isalnum()0    False1    False2    Falsedtype: bool

More Detailed Checks for Numeric Characters

There are several different but overlapping sets of numeric characters thatcan be checked for.

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

Thes3.str.isdecimal method checks for characters used to form numbersin base 10.

>>>s3.str.isdecimal()0     True1    False2    False3    Falsedtype: bool

Thes.str.isdigit method is the same ass3.str.isdecimal but alsoincludes special digits, like superscripted and subscripted digits inunicode.

>>>s3.str.isdigit()0     True1     True2    False3    Falsedtype: bool

Thes.str.isnumeric method is the same ass3.str.isdigit but alsoincludes other characters that can represent quantities such as unicodefractions.

>>>s3.str.isnumeric()0     True1     True2     True3    Falsedtype: bool

Checks for Whitespace

>>>s4=pd.Series([' ','\t\r\n ',''])>>>s4.str.isspace()0     True1     True2    Falsedtype: bool

Checks for Character Case

>>>s5=pd.Series(['leopard','Golden Eagle','SNAKE',''])
>>>s5.str.islower()0     True1    False2    False3    Falsedtype: bool
>>>s5.str.isupper()0    False1    False2     True3    Falsedtype: bool

Thes5.str.istitle method checks for whether all words are in titlecase (whether only the first letter of each word is capitalized). Words areassumed to be as any sequence of non-numeric characters separated bywhitespace characters.

>>>s5.str.istitle()0    False1     True2    False3    Falsedtype: bool

[8]ページ先頭

©2009-2025 Movatter.jp