pandas.Series.str.isdigit — pandas 3.0.0rc0+40.gecf28e538a documentation (original) (raw)

Series.str.isdigit()[source]#

Check whether all characters in each string are digits.

This is equivalent to running the Python string methodstr.isdigit() for each element of the Series/Index. If a string has 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 original Series/Index.

Notes

Similar to str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.

The exact behavior of this method, i.e. which unicode characters are considered as digits, depends on the backend used for string operations, and there can be small differences. For example, Python considers the ³ superscript character as a digit, but not the ⅕ fraction character, while PyArrow considers both as digits. For simple (ascii) decimal numbers, the behaviour is consistent.

Examples

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