pandas.Series.str.isspace

Check whether all characters in each string are whitespace.

This is equivalent to running the Python string method str.isspace() for each element of the Series/Index. If a string has zero characters, False is returned for that check.

return

Series or Index of bool Series or Index of boolean values with the same length as the original Series/Index.

Limitations

This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff between staying in JIT-region with that function or going back to interpreter mode.

Examples

Check if all the characters in the text are whitespaces
import pandas as pd
from numba import njit


@njit
def series_str_isspace():
    series = pd.Series([' ', ' c ', '  b ', '     a     '])
    out_series = series.str.isspace()

    return out_series  # Expect series of True, False, False, False


print(series_str_isspace())
$ python ./series/str/series_str_isspace.py
0     True
1    False
2    False
3    False
dtype: bool

See also

Series.str.isalpha

Checks whether all characters are alphabetic.

Series.str.isnumeric

Checks whether all characters are numeric.

Series.str.isalnum

Checks whether all characters are alphanumeric.

Series.str.isdigit

Checks whether all characters are digits.

Series.str.isdecimal

Checks whether all characters are decimal.

Series.str.isspace

Checks whether all characters are whitespace.

Series.str.islower

Checks whether all characters are lowercase.

Series.str.isupper

Checks whether all characters are uppercase.

Series.str.istitle

Checks whether all characters are titlecase.