Repeat elements of a Index.
Returns a new Index where each element of the current Index is repeated consecutively a given number of times.
The number of repetitions for each element. This should be a non-negative integer. Repeating 0 times will return an empty Index.
Must be None. Has no effect but is accepted for compatibility with numpy.
Newly created Index with repeated elements.
See also
Series.repeatEquivalent function for Series.
numpy.repeatSimilar method for numpy.ndarray.
Examples
>>> 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')
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.Index.repeat.html