cudf.Series.repeat#
- Series.repeat(repeats, axis=None)[source]#
Repeats elements consecutively.
Returns a new object of caller type(DataFrame/Series) where each element of the current object is repeated consecutively a given number of times.
- Parameters:
- repeatsint, 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 object.
- Returns:
- Series/DataFrame
A newly created object of same type as caller with repeated elements.
Examples
>>> import cudf >>> df = cudf.DataFrame({'a': [1, 2, 3], 'b': [10, 20, 30]}) >>> df a b 0 1 10 1 2 20 2 3 30 >>> df.repeat(3) a b 0 1 10 0 1 10 0 1 10 1 2 20 1 2 20 1 2 20 2 3 30 2 3 30 2 3 30
Repeat on Series
>>> s = cudf.Series([0, 2]) >>> s 0 0 1 2 dtype: int64 >>> s.repeat([3, 4]) 0 0 0 0 0 0 1 2 1 2 1 2 1 2 dtype: int64 >>> s.repeat(2) 0 0 0 0 1 2 1 2 dtype: int64