Table Of Contents

Search

Enter search terms or a module, class or function name.

pandas.Series.str.repeat

Series.str.repeat(repeats)[source]

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

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
Scroll To Top