xorbits.pandas.Series.repeat#
- Series.repeat(repeats: int | Sequence[int], axis: None = None) Series [源代码]#
Repeat elements of a Series.
Returns a new Series where each element of the current Series is repeated consecutively a given number of times.
- 参数
repeats (int or array of ints) – The number of repetitions for each element. This should be a non-negative integer. Repeating 0 times will return an empty Series.
axis (None) – Unused. Parameter needed for compatibility with DataFrame.
- 返回
Newly created Series with repeated elements.
- 返回类型
参见
Index.repeat
Equivalent function for Index.
numpy.repeat
Similar method for
numpy.ndarray
.
实际案例
>>> s = pd.Series(['a', 'b', 'c']) >>> s 0 a 1 b 2 c dtype: object >>> s.repeat(2) 0 a 0 a 1 b 1 b 2 c 2 c dtype: object >>> s.repeat([1, 2, 3]) 0 a 1 b 1 b 2 c 2 c 2 c dtype: object
警告
This method has not been implemented yet. Xorbits will try to execute it with pandas.
This docstring was copied from pandas.core.series.Series.