NumPy String: numpy.char.islower() function
numpy.char.islower() function
The numpy.char.islower() function returns true for each element if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.
This function can be useful in various text processing tasks, such as identifying if a given word is in lower case or not, filtering out strings that contain upper case letters etc.
Syntax:
numpy.char.islower(a)
Parameter:
Name | Description | Required / Optional |
---|---|---|
a: array_like, unicode | Input an array_like of string or unicode. | Required |
Return value:
Returns an array of boolean values where True indicates that the character is in lower case and False indicates that the character is not in lower case.
Example: NumPy - Detecting lowercase characters in a string
>>> import numpy as np
>>> x = np.char.islower('APPLE')
>>> x
array(False)
In the said code, numpy.char.islower() function is applied on the string "APPLE". Since "APPLE" contains only uppercase characters, the output of numpy.char.islower() is False.
Pictorial Presentation:
Example: Checking if a string is in lowercase using numpy.char.islower()
>>> import numpy as np
>>> y = np.char.islower('apple')
>>> y
array(True)
In the above example, the string "apple" is passed to the function and it returns a boolean value "True" since all the characters in the string are in lowercase.
Pictorial Presentation:
Example: NumPy - Check if a string is in lowercase
>>> import numpy as np
>>> z = np.char.islower('apple BASKET')
>>> z
array(False)
In the above example, the code checks if the string "apple BASKET" is in lowercase or not. Since it is not in lowercase, the function returns False.
Pictorial Presentation:
Python - NumPy Code Editor:
Previous:
isdigit()
Next:
isnumeric()
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/numpy/string-operations/islower.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics