- API reference
- Series
- pandas.Serie...
pandas.Series.str.repeat#
- Series.str.repeat(repeats)[source]#
Duplicate each string in the Series or Index.
- Parameters:
- repeatsint or sequence of int
Same value for all (int) or different value per (sequence).
- Returns:
- Series or pandas.Index
Series or Index of repeated string objects specified byinput parameter repeats.
Examples
>>>s=pd.Series(['a','b','c'])>>>s0 a1 b2 cdtype: object
Single int repeats string in Series
>>>s.str.repeat(repeats=2)0 aa1 bb2 ccdtype: object
Sequence of int repeats corresponding string in Series
>>>s.str.repeat(repeats=[1,2,3])0 a1 bb2 cccdtype: object
On this page