Skip to content

Commit

Permalink
DOC: Updating str_repeat docstring (pandas-dev#22571)
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperDramsch authored and aeltanawy committed Sep 20, 2018
1 parent 3c6ad7d commit 4310671
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,20 +678,42 @@ def str_replace(arr, pat, repl, n=-1, case=None, flags=0, regex=True):

def str_repeat(arr, repeats):
"""
Duplicate each string in the Series/Index by indicated number
of times.
Duplicate each string in the Series or Index.
Parameters
----------
repeats : int or array
Same value for all (int) or different value per (array)
repeats : int or sequence of int
Same value for all (int) or different value per (sequence).
Returns
-------
repeated : Series/Index of objects
Series or Index of object
Series or Index of repeated string objects specified by
input parameter repeats.
Examples
--------
>>> s = pd.Series(['a', 'b', 'c'])
>>> s
0 a
1 b
2 c
Single int repeats string in Series
>>> s.str.repeat(repeats=2)
0 aa
1 bb
2 cc
Sequence of int repeats corresponding string in Series
>>> s.str.repeat(repeats=[1, 2, 3])
0 a
1 bb
2 ccc
"""
if is_scalar(repeats):

def rep(x):
try:
return compat.binary_type.__mul__(x, repeats)
Expand Down

0 comments on commit 4310671

Please sign in to comment.