pandas.Index.repeat
-
Index.repeat(repeats, *args, **kwargs)
[source] -
Repeat elements of an Index.
Returns a new index where each element of the current index is repeated consecutively a given number of times.
Parameters: repeats : int
The number of repetitions for each element.
**kwargs
Additional keywords have no effect but might be accepted for compatibility with numpy.
Returns: pandas.Index
Newly created Index with repeated elements.
See also
-
Series.repeat
- Equivalent function for Series
-
numpy.repeat
- Underlying implementation
Examples
>>> idx = pd.Index([1, 2, 3]) >>> idx Int64Index([1, 2, 3], dtype='int64') >>> idx.repeat(2) Int64Index([1, 1, 2, 2, 3, 3], dtype='int64') >>> idx.repeat(3) Int64Index([1, 1, 1, 2, 2, 2, 3, 3, 3], dtype='int64')
-
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.Index.repeat.html