numpy.core.defchararray.isspace (arr) returns true for each item if the string contains only whitespace and at least one character. Returns false otherwise.
Syntax: numpy.core.isspace (arr)
arr: array_like of str or unicode.
Returns: [ndarray] Output array of bools.
Code # 1:
Input array: [`Geeksforgeeks`` Codechef`] Output array: [False False]
Code # 2:
Exit:< pre> Input array: [`Geeks for geeks`` Code chef`] Output array: [False False]
Code # 3:
Input array: [`` `` `` `] Output array: [True True True True]
def is_not_blank(s): return bool(s and not s.isspace())
print is_not_blank("") # False print is_not_blank(" ") # False print is_not_blank("ok") # True print is_not_blank(None) # False
Trueif there are only whitespace characters in the string and there is at least one character,
A character is whitespace if in the Unicode character database (see unicodedata), either its general category is Zs (‚ÄúSeparator, space‚Äù), or its bidirectional class is one of WS, B, or S.
Combine that with a special case for handling the empty string.
Alternatively, you could use
str.strip() and check if the result is empty.
Why not use
title Right from the docs:
>>> "they"re bill"s friends from the UK".title() "They"Re Bill"S Friends From The Uk"
If you really wanted PascalCase you can use this:
>>> "".join(x for x in "make IT pascal CaSe".title() if not x.isspace()) "MakeItPascalCase"
Introduction to Machine Learning with Python: A Guide for Data Scientists 1st Edition. Machine learning has become an integral part of many commercial applications and research projects, but this f...
The series “Studies in Big Data” (SBD) publishes new developments and advances in the various areas of Big Data-quickly and with a high quality. The intent is to cover the theory, research, develo...
R for Everyone: Advanced Analytics and Graphics. ...
Managing and analyzing data have always offered the greatest benefits and the greatest challenges for organizations of all sizes and across all industries. Businesses have long struggled with finding ...