Pandas Series: str.isdecimal() function
Series-str.isdecimal() function
The str.isdecimal() function is used to check whether all characters in each string are decimal or not.
This is equivalent to running the Python string method str.isdecimal() for each element of the Series/Index. If a string has zero characters, False is returned for that check.
Syntax:
Series.str.isdecimal(self)
Returns: Series or Index of bool
Series or Index of boolean values with the same length as the original Series/Index.
More Detailed Checks for Numeric Characters
There are several different but overlapping sets of numeric characters that can be checked for.
Example - The s1.str.isdecimal method checks for characters used to form numbers in base 10:
Python-Pandas Code:
import numpy as np
import pandas as pd
s1 = pd.Series(['22', '³', '⅕', ''])
s1.str.isdecimal()
Output:
0 True 1 False 2 False 3 False dtype: bool
Previous: Series-str.isnumeric() function
Next: Series-str.get_dummies() 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-isdecimal.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics