Skip to content

Commit

Permalink
Update the pandas.Series.str.repeat docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
manojpandey committed Sep 2, 2018
1 parent 6d610a4 commit b023d7a
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,17 +594,44 @@ 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 repeated by indicated number of times.
Duplicate each string in the Series/Index by indicated number of times.
A passed value of zero or negative integer will return an empty string.
Parameters
----------
repeats : int or array
Same value for all (int) or different value per (array)
repeats : int or array-like
Same value for all (int) or different value per (array).
Returns
-------
repeated : Series/Index of objects
Series or Index
Same type as the original object
Examples
--------
>>> s = pd.Series(['a', 'b', 'c', 'd', 'e'])
Using same value for all:
>>> s.str.repeat(4)
0 aaaa
1 bbbb
2 cccc
3 dddd
4 eeee
dtype: object
Using different value per element:
>>> s.str.repeat([-3, 0, 5, 1, 4])
0
1
2 ccccc
3 d
4 eeee
dtype: object
"""
if is_scalar(repeats):

Expand Down

0 comments on commit b023d7a

Please sign in to comment.