pyspark.pandas.Series.str.len

str.len() → pyspark.pandas.series.Series

Computes the length of each element in the Series.

The element may be a sequence (such as a string, tuple or list).

Returns
Series of int

A Series of integer values indicating the length of each element in the Series.

Examples

Returns the length (number of characters) in a string. Returns the number of entries for lists or tuples.

>>> s1 = ps.Series(['dog', 'monkey'])
>>> s1.str.len()
0    3
1    6
dtype: int64
>>> s2 = ps.Series([["a", "b", "c"], []])
>>> s2.str.len()
0    3
1    0
dtype: int64