pandas.Series.str.repeat#

Series.str.repeat(repeats)[源代码]#

复制系列或索引中的每个字符串。

参数
repeats整型或整型序列

所有(整型)的值相同或每个(序列)的值不同。

退货
对象的系列或索引

由输入参数重复指定的重复字符串对象的序列或索引。

示例

>>> s = pd.Series(['a', 'b', 'c'])
>>> s
0    a
1    b
2    c
dtype: object

单个整型重复序列中的字符串

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

INT序列重复序列中相应的字符串

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