def str_repeat(arr, repeats):
if is_scalar(repeats):<EOL><INDENT>def scalar_rep(x):<EOL><INDENT>try:<EOL><INDENT>return bytes.__mul__(x, repeats)<EOL><DEDENT>except TypeError:<EOL><INDENT>return str.__mul__(x, repeats)<EOL><DEDENT><DEDENT>return _na_map(scalar_rep, arr)<EOL><DEDENT>else:<EOL><INDENT>def rep(x, r):<EOL><INDENT>try:<EOL><INDENT>return bytes.__mul__(x, r)<EOL><DEDENT>except TypeError:<EOL><INDENT>return str.__mul__(x, r)<EOL><DEDENT><DEDENT>repeats = np.asarray(repeats, dtype=object)<EOL>result = libops.vec_binop(com.values_from_object(arr), repeats, rep)<EOL>return result<EOL><DEDENT>
Duplicate each string in the Series or Index.

Parameters
----------
repeats : int or sequence of int
    Same value for all (int) or different value per (sequence).

Returns
-------
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
dtype: object

Single int repeats string in Series

>>> s.str.repeat(repeats=2)
0    aa
1    bb
2    cc
dtype: object

Sequence of int repeats corresponding string in Series

>>> s.str.repeat(repeats=[1, 2, 3])
0      a
1     bb
2    ccc
dtype: object