pyspark.pandas.Series.get

Series.get(key: Any, default: Optional[Any] = None) → Any

Get item from object for given key (DataFrame column, Panel slice, etc.). Returns default value if not found.

Parameters
keyobject
Returns
valuesame type as items contained in object

Examples

>>> df = ps.DataFrame({'x':range(3), 'y':['a','b','b'], 'z':['a','b','b']},
...                   columns=['x', 'y', 'z'], index=[10, 20, 20])
>>> df
    x  y  z
10  0  a  a
20  1  b  b
20  2  b  b
>>> df.get('x')
10    0
20    1
20    2
Name: x, dtype: int64
>>> df.get(['x', 'y'])
    x  y
10  0  a
20  1  b
20  2  b
>>> df.x.get(10)
0
>>> df.x.get(20)
20    1
20    2
Name: x, dtype: int64
>>> df.x.get(15, -1)
-1