w3resource

Pandas Series: repeat() function

Repeat elements of a Pandas series

The repeat() function is used to repeat elements of a Series.

Returns a new Series where each element of the current Series is repeated consecutively a given number of times.

Syntax:

Series.repeat(self, repeats, axis=None)
Pandas Series repeat image
Name Description Type/Default Value Required / Optional
repeats The number of repetitions for each element. This should be a non-negative integer. Repeating 0 times will return an empty Series. int or array of ints Required
axis Must be None. Has no effect but is accepted for compatibility with numpy. Default Value: None Required

Returns: Series- Newly created Series with repeated elements.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts