pyspark.pandas.Series.str.get

str.get(i: int) → pyspark.pandas.series.Series

Extract element from each string or string list/tuple in the Series at the specified position.

Parameters
iint

Position of element to extract.

Returns
Series of objects

Examples

>>> s1 = ps.Series(["String", "123"])
>>> s1
0    String
1       123
dtype: object
>>> s1.str.get(1)
0    t
1    2
dtype: object
>>> s1.str.get(-1)
0    g
1    3
dtype: object
>>> s2 = ps.Series([["a", "b", "c"], ["x", "y"]])
>>> s2
0    [a, b, c]
1       [x, y]
dtype: object
>>> s2.str.get(0)
0    a
1    x
dtype: object
>>> s2.str.get(2)
0       c
1    None
dtype: object