- API reference
- Series
- pandas.Serie...
pandas.Series.str.get#
- Series.str.get(i)[source]#
Extract element from each component at specified position or with specified key.
Extract element from lists, tuples, dict, or strings in each element in theSeries/Index.
- Parameters:
- iint or hashable dict label
Position or key of element to extract.
- Returns:
- Series or Index
Examples
>>>s=pd.Series(["String",...(1,2,3),...["a","b","c"],...123,...-456,...{1:"Hello","2":"World"}])>>>s0 String1 (1, 2, 3)2 [a, b, c]3 1234 -4565 {1: 'Hello', '2': 'World'}dtype: object
>>>s.str.get(1)0 t1 22 b3 NaN4 NaN5 Hellodtype: object
>>>s.str.get(-1)0 g1 32 c3 NaN4 NaN5 Nonedtype: object
Return element with given key
>>>s=pd.Series([{"name":"Hello","value":"World"},...{"name":"Goodbye","value":"Planet"}])>>>s.str.get('name')0 Hello1 Goodbyedtype: object
On this page