Index.repeat()
Pandas Index.repeat()
repeats index items. The function returns a new index, where each element of the current index is repeated a specified number of times.
Syntax: Index.repeat (repeats, * args, ** kwargs)
Parameters:
repeats: The number of repetitions for each element.
** kwargs: Additional keywords have no effect but might be accepted for compatibility with numpy.Returns: Newly created Index with repeated elements.
Example # 1: Use Index.repeat () ()
to repeat index items 2 times.
|
Output:
Let’s repeat the index items 2 times.
|
Output:
As we can see in the output, the function returned a new index with all values repeated 2 times. It’s important to note that the function also repeated the NaN
value.
Example # 2: Use Index.repeat ()
to repeat index value 3 times.
|
Output:
Let’s repeat the index items 3 times.
|
Exit:
As we can see in the output, the function returned a new index with all values, repeated 3 times. It’s important to note that the function also repeated the NaN
value.