Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

NumPy: isnumeric() function

numpy.core.defchararray.isnumeric() function

For each element the numpy.core.defchararray.isnumeric() function returns True if there are only numeric characters in the element.

Version: 1.15.0

Syntax:

numpy.core.defchararray.isnumeric(a)

Parameter:

Name Description Required /
Optional
a: array_like, unicode Input array. Required

Return value:

out : ndarray, bool - Array of booleans of same shape as a.

Note:

The 'chararray' class exists for backwards compatibility with Numarray, it is not recommended for new development. Starting from numpy 1.4, if one needs arrays of strings, it is recommended to use arrays of 'dtype' 'object_', 'string_' or 'unicode_', and use the free functions in the 'numpy.char' module for fast vectorized string operations.

Some methods will only be available if the corresponding string method is available in your version of Python.

The preferred alias for 'defchararray' is 'numpy.char'.

Example-1: numpy.isnumeric() function

>>> import numpy as np
>>> x = np.char.isnumeric('APPLE')
>>> x
array(False)

Pictorial Presentation:

NumPy String operation: isnumeric() function

Example-2: numpy.isnumeric() function

>>> import numpy as np
>>> y = np.char.isnumeric('12345')
>>> y
array(True)

Pictorial Presentation:

NumPy String operation: isnumeric() function

Python - NumPy Code Editor:

Example-3: numpy.isnumeric() function

>>> import numpy as np
>>> z = np.char.isnumeric('12345APPLE')
>>> z
array(False)

Pictorial Presentation:

NumPy String operation: isnumeric() function

Python - NumPy Code Editor:

Previous: islower()
Next: isspace()