Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
isdecimal() is used to check whether all characters in a string are decimal. This method works in a similar way to str.isdigit() method, but there is a difference that the latter is more expansive with respect to non ASCII digits. This will be cleared with the help of an example.
Return type: Boolean series
In this example, a new data frame is created with just one column and some values are passed to it. Then str.isdecimal() method is called on that column and output is returned to a new column Bool.
As shown in the output image, the decimal returns True for decimal values in string form. If the element is in int, float or any other data type other than string, NaN is returned ( No matter if it’s a decimal number )
In this example, numbers with power are also added to that column. Both str isdigit() and str.isdecimal() are called and output is stored in different columns to compare the difference between both.
As shown in the Output image, the isdigit () returns True for numbers with power but isdecimal () returns False for those values.
- Python | pandas.map()
- Python | Pandas Series.mod()
- Python | Pandas Dataframe.at[ ]
- Python | Pandas Series.ne()
- Python | Pandas Dataframe.iat[ ]
- Python | Pandas dataframe.add()
- Python | Pandas Series.eq()
- Python | Pandas dataframe.cov()
- Python | Pandas TimedeltaIndex.contains
- Python | Pandas DataFrame.ix[ ]
- Python | Pandas Index.contains()
- Python | Pandas Panel.pow()
- Python | Pandas DataFrame.abs()
- Python | Pandas dataframe.all()
- Python | Pandas Timestamp.tz
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.