numpy string operations | isdecimal() function (original) (raw)
Last Updated : 14 Jan, 2019
numpy.core.defchararray.isdecimal(arr)
function returns True for each element if there are only decimal characters in the element.It returns false otherwise.
Parameters: arr : array_like of str or unicode.Returns : [ndarray] Output array of bools.
Code #1 :
Python3 `
Python program explaining
numpy.char.isdecimal() method
import numpy as geek
input array contains only digits
in_arr = geek.array([ '1000', '2000'] ) print ("Input array : ", in_arr)
out_arr = geek.char.isdecimal(in_arr) print ("Output array: ", out_arr)
`
Output:
Input array : ['1000' '2000'] Output array: [ True True]
Code #2 :
Python3 `
Python program explaining
numpy.char.isdecimal() method
import numpy as geek
input array contains digits along with space and alphabets
in_arr = geek.array([ '1000 2', 'a1000', '1234 ab'] ) print ("Input array : ", in_arr)
out_arr = geek.char.isdecimal(in_arr) print ("Output array: ", out_arr)
`
Output:
Input array : ['1000 2' 'a1000' '1234 ab'] Output array: [False False False]
Similar Reads
- numpy string operations | isdigit() function numpy.core.defchararray.isdigit(arr) function returns True for each element if all characters in the string are digits and there is at least one character; returns false otherwise. Parameters: arr : array_like of str or unicode. Returns : [ndarray] Output array of bools. Code #1 : # Python program e 1 min read
- numpy string operations | isalpha() function numpy.core.defchararray.isalpha(arr) function returns True for each element if all characters in the string are alphabetic and there is at least one character; returns false otherwise. Parameters: arr : array_like of str or unicode. Returns : [ndarray] Output array of bools. Code #1 : # Python progr 1 min read
- numpy string operations | istitle() function numpy.core.defchararray.istitle(arr) function returns True for each element in the array if the element is a titlecased string and there is at least one character, it returns false otherwise. Parameters: arr : array_like of str or unicode Returns : [ndarray] Output array of bools. Code #1: # Python 1 min read
- numpy string operations | isnumeric() function numpy.core.defchararray.isnumeric(arr) function returns true for each element if there are only numeric characters and there is at least one character.It returns false otherwise. Parameters: arr : array_like of str or unicode. Returns : [ndarray] Output array of bools. Code #1 : # Python program exp 1 min read
- numpy string operations | islower() function numpy.core.defchararray.islower(arr) function returns True for each element if all cased characters in the string are lowercase and there is at least one cased character, It returns false otherwise. Parameters: arr : array_like of str or unicode Returns : [ndarray] Output array of bools. Code #1: # 1 min read
- numpy string operations | equal() function numpy.core.defchararray.equal(arr1, arr2) is another function for doing string operations in numpy. It checks the elements of two same-shaped array one by one and returns True if they are equal. Otherwise, it returns False. Parameters: arr1 : array_like of str or unicode. arr2 : array_like of str or 2 min read
- numpy string operations | not_equal() function numpy.core.defchararray.not_equal(arr1, arr2) is another function for doing string operations in numpy. It checks the elements of two same shaped array one by one and returns True if they are not equal. Otherwise, it returns False. Parameters: arr1 : array_like of str or unicode. arr2 : array_like o 2 min read
- Python | numpy.issubdtype() function numpy.issubdtype() function is used to determine whether the first argument is a typecode lower/equal in type hierarchy from second argument.If the first argument is lower or equal it returns true, otherwise it returns false. Syntax : numpy.issubdtype(arg1, arg2) Parameters : arg1, arg2 : [dtype_lik 1 min read
- Convert Decimal to String in Python Python defines type conversion functions to directly convert one data type to another. This article is aimed at providing the information about converting decimal to string. Converting Decimal to String str() method can be used to convert decimal to string in Python. Syntax: str(object, encoding=’ut 1 min read
- Python string isdecimal() Method In Python, the isdecimal() method is a quick and easy way to check if a string contains only decimal digits. It works by returning True when the string consists of digits from 0 to 9 and False otherwise. This method is especially useful when we want to ensure that user inputs or string data are stri 3 min read