Skip to content

Commit 16047d0

Browse files
JesperDramschvictor
authored and
victor
committed
DOC: Updating str_repeat docstring (pandas-dev#22571)
1 parent 82691b3 commit 16047d0

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

pandas/core/strings.py

+28-6
Original file line numberDiff line numberDiff line change
@@ -678,20 +678,42 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):
678678

679679
def str_repeat(arr, repeats):
680680
"""
681-
Duplicate each string in the Series/Index by indicated number
682-
of times.
681+
Duplicate each string in the Series or Index.
683682
684683
Parameters
685684
----------
686-
repeats : int or array
687-
Same value for all (int) or different value per (array)
685+
repeats : int or sequence of int
686+
Same value for all (int) or different value per (sequence).
688687
689688
Returns
690689
-------
691-
repeated : Series/Index of objects
690+
Series or Index of object
691+
Series or Index of repeated string objects specified by
692+
input parameter repeats.
693+
694+
Examples
695+
--------
696+
>>> s = pd.Series(['a', 'b', 'c'])
697+
>>> s
698+
0 a
699+
1 b
700+
2 c
701+
702+
Single int repeats string in Series
703+
704+
>>> s.str.repeat(repeats=2)
705+
0 aa
706+
1 bb
707+
2 cc
708+
709+
Sequence of int repeats corresponding string in Series
710+
711+
>>> s.str.repeat(repeats=[1, 2, 3])
712+
0 a
713+
1 bb
714+
2 ccc
692715
"""
693716
if is_scalar(repeats):
694-
695717
def rep(x):
696718
try:
697719
return compat.binary_type.__mul__(x, repeats)

0 commit comments

Comments
 (0)