Skip to content

Commit 0ae19a1

Browse files
pranavsurijreback
authored andcommitted
DOC: Updated the docstring of pandas.Series.str.get (#20667)
1 parent efabfc8 commit 0ae19a1

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

pandas/core/strings.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -1667,17 +1667,53 @@ def str_translate(arr, table, deletechars=None):
16671667

16681668
def str_get(arr, i):
16691669
"""
1670+
Extract element from each component at specified position.
1671+
16701672
Extract element from lists, tuples, or strings in each element in the
16711673
Series/Index.
16721674
16731675
Parameters
16741676
----------
16751677
i : int
1676-
Integer index (location)
1678+
Position of element to extract.
16771679
16781680
Returns
16791681
-------
16801682
items : Series/Index of objects
1683+
1684+
Examples
1685+
--------
1686+
>>> s = pd.Series(["String",
1687+
(1, 2, 3),
1688+
["a", "b", "c"],
1689+
123, -456,
1690+
{1:"Hello", "2":"World"}])
1691+
>>> s
1692+
0 String
1693+
1 (1, 2, 3)
1694+
2 [a, b, c]
1695+
3 123
1696+
4 -456
1697+
5 {1: 'Hello', '2': 'World'}
1698+
dtype: object
1699+
1700+
>>> s.str.get(1)
1701+
0 t
1702+
1 2
1703+
2 b
1704+
3 NaN
1705+
4 NaN
1706+
5 Hello
1707+
dtype: object
1708+
1709+
>>> s.str.get(-1)
1710+
0 g
1711+
1 3
1712+
2 c
1713+
3 NaN
1714+
4 NaN
1715+
5 NaN
1716+
dtype: object
16811717
"""
16821718
def f(x):
16831719
if isinstance(x, dict):

0 commit comments

Comments
 (0)