What is the numpy.char.isspace() function from NumPy in Python?

Overview

The char.isspace() function in Python returns True for each element of a string's input array if there are only whitespace characters in the given string and there is at least a character. Otherwise, it returns False.

Syntax

char.isspace(a)
Syntax for char.isspace() function

Parameter value

The char.isspace() function takes a single parameter value, a, which represents the input array of string.

Return value

The char.isspace() function returns an output array of Boolean values with the same shape as the input array a.

Example

import numpy as np
# creating different array objects
a = np.array([" ", 'Hi Dear', "Tiebreaker"])
# implementing the char.isspace() function
myarray = np.char.isspace(a)
# printing the input array
print(a)
# printing the output array
print(myarray)
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources