xorbits.pandas.Index.repeat#

Index.repeat(repeats, axis=None)[源代码]#

Repeat elements of a Index.

Returns a new Index where each element of the current Index 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 Index.

  • axis (None) – Must be None. Has no effect but is accepted for compatibility with numpy.

返回

Newly created Index with repeated elements.

返回类型

Index

参见

Series.repeat

Equivalent function for Series.

numpy.repeat

Similar method for numpy.ndarray.

实际案例

>>> idx = pd.Index(['a', 'b', 'c'])  
>>> idx  
Index(['a', 'b', 'c'], dtype='object')
>>> idx.repeat(2)  
Index(['a', 'a', 'b', 'b', 'c', 'c'], dtype='object')
>>> idx.repeat([1, 2, 3])  
Index(['a', 'b', 'b', 'c', 'c', '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.indexes.base.Index.