Dark Mode On/Off
LAST UPDATED: DECEMBER 10, 2020

# NumPy isdecimal() function

In this tutorial, we will cover `isdecimal()` function of the char module in Numpy library.

The `isdecimal()` function returns True if there are only decimal characters in the element, otherwise, this function will return False.

This function calls `unicode.isdecimal` for every string element of the array.

It is important to note that the decimal characters include digit characters and all those characters that can be used to form decimal-radix numbers, e.g. U+0661, ARABIC-INDIC DIGIT ONE, etc.

### Syntax of `isdecimal()`:

The syntax required to use this function is as follows:

``numpy.char.isdecimal(arr)``

The above syntax indicates that `isdecimal()` function takes a single parameter.

In the above syntax, the argument `arr` is mainly used to indicate the input array of strings.

Returned Values:

This function will return an Output array of boolean values having a shape similar to the Input array.

## Example 1:

In this code example, we will use the `isdecimal()` function with a simple string:

``````import numpy as np

string1 = "12342"
print("The Input string is:")
print(string1)

x = np.char.isdecimal(string1)
print("The Output is:")
print(x)``````

The Input string is:
12342
The Output is:
True

## Example 2:

In the below code snippet we will use the `isdecimal()` function on an array of strings:

``````import numpy as np

inp_ar = np.array([ '20002 2', 'a10009', '12345 ab','01'] )
print("The Input string is:")
print(inp_ar)

x = np.char.isdecimal(inp_ar)
print("The Output is:")
print(x)``````

The Input string is:
['20002 2' 'a10009' '12345 ab' '01']
The Output is:
[False False False True]

## Summary

In this tutorial we learned about the `isdecimal()` function in the Numpy library. We covered how it is used with its syntax and values returned by this function along with multiple code examples.

Want to learn coding?
Try our new interactive courses.
Over 20,000+ students enrolled.