maxframe.dataframe.Series.str.repeat#

Series.str.repeat(repeats)#

重复 Series 或 Index 中的每个字符串。

Duplicates each string in the Series or Index, either by applying the same repeat count to all elements or by using different repeat values for each element.

参数:

repeats (int or sequence of int) -- 所有元素使用相同值(int)或每个元素使用不同值(序列)。

返回:

由输入参数 repeats 指定的重复字符串对象组成的 Series 或 Index。

返回类型:

Series or pandas.Index

参见

Series.str.lower

Convert all characters in each string to lowercase.

Series.str.upper

Convert all characters in each string to uppercase.

Series.str.title

Convert each string to title case (capitalizing the first letter of each word).

Series.str.strip

Remove leading and trailing whitespace from each string.

Series.str.replace

Replace occurrences of a substring with another substring in each string.

Series.str.ljust

Left-justify each string in the Series/Index by padding with a specified character.

Series.str.rjust

Right-justify each string in the Series/Index by padding with a specified character.

示例

>>> import maxframe.dataframe as md
>>> s = md.Series(["a", "b", "c"])
>>> s.execute()
0    a
1    b
2    c
dtype: str

使用单个整数重复 Series 中的字符串

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

使用整数序列重复 Series 中对应的字符串

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