pyspark.pandas.Series.str.join

str.join(sep: str) → pyspark.pandas.series.Series

Join lists contained as elements in the Series with passed delimiter.

If the elements of a Series are lists themselves, join the content of these lists using the delimiter passed to the function. This function is an equivalent to calling str.join() on the lists.

Parameters
sepstr

Delimiter to use between list entries.

Returns
Series of object

Series with list entries concatenated by intervening occurrences of the delimiter.

See also

str.split

Split strings around given separator/delimiter.

str.rsplit

Splits string around given separator/delimiter, starting from the right.

Examples

Example with a list that contains a None element.

>>> s = ps.Series([['lion', 'elephant', 'zebra'],
...                ['cat', None, 'dog']])
>>> s
0    [lion, elephant, zebra]
1           [cat, None, dog]
dtype: object

Join all lists using a ‘-‘. The list containing None will produce None.

>>> s.str.join('-')
0    lion-elephant-zebra
1                   None
dtype: object