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.str.lowerConvert all characters in each string to lowercase.
Series.str.upperConvert all characters in each string to uppercase.
Series.str.titleConvert each string to title case (capitalizing the first letter of each word).
Series.str.stripRemove leading and trailing whitespace from each string.
Series.str.replaceReplace occurrences of a substring with another substring in each string.
Series.str.ljustLeft-justify each string in the Series/Index by padding with a specified character.
Series.str.rjustRight-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