Pandas Series: str.isdigit() function
Series-str.isdigit() function
The str.isdigit() function is used to Check whether all characters in each string are digits.
This is equivalent to running the Python string method str.isdigit() for each element of the Series/Index. If a string has zero characters, False is returned for that check.
Syntax:
Series.str.isdigit(self)
Returns:Series or Index of bool
Series or Index of boolean values with the same length as the original Series/Index
Example - Checks for Alphabetic and Numeric Characters:
The s.str.isdigit method is the same as s3.str.isdecimal but also includes special digits, like superscripted and subscripted digits in unicode.
Python-Pandas Code:
import numpy as np
import pandas as pd
s3 = pd.Series(['25', '³', '⅕', ''])
s3.str.isdigit()
Output:
0 True 1 True 2 False 3 False dtype: bool
The s.str.isnumeric method is the same as s3.str.isdigit but also includes other characters that can represent quantities such as unicode fractions.
Previous: Series-str.isalpha() function
Next: Series-str.isspace() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/pandas/series/series-str-isdigit.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics