Skip to content

Commit b023d7a

Browse files
committed
Update the pandas.Series.str.repeat docstring
1 parent 6d610a4 commit b023d7a

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

pandas/core/strings.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,17 +594,44 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
594594

595595
def str_repeat(arr, repeats):
596596
"""
597-
Duplicate each string in the Series/Index by indicated number
598-
of times.
597+
Duplicate each string repeated by indicated number of times.
598+
599+
Duplicate each string in the Series/Index by indicated number of times.
600+
A passed value of zero or negative integer will return an empty string.
599601
600602
Parameters
601603
----------
602-
repeats : int or array
603-
Same value for all (int) or different value per (array)
604+
repeats : int or array-like
605+
Same value for all (int) or different value per (array).
604606
605607
Returns
606608
-------
607-
repeated : Series/Index of objects
609+
Series or Index
610+
Same type as the original object
611+
612+
Examples
613+
--------
614+
>>> s = pd.Series(['a', 'b', 'c', 'd', 'e'])
615+
616+
Using same value for all:
617+
618+
>>> s.str.repeat(4)
619+
0 aaaa
620+
1 bbbb
621+
2 cccc
622+
3 dddd
623+
4 eeee
624+
dtype: object
625+
626+
Using different value per element:
627+
628+
>>> s.str.repeat([-3, 0, 5, 1, 4])
629+
0
630+
1
631+
2 ccccc
632+
3 d
633+
4 eeee
634+
dtype: object
608635
"""
609636
if is_scalar(repeats):
610637

0 commit comments

Comments
 (0)