Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-239

Series Padding

Problem

Right-pad a series with pad_value until it reaches target_length. If the series is already at least that long, return it unchanged.

Return the padded list.

Hint

Padding aligns variable-length series for batched training.

Test cases

case 1
in: [[1,2,3],5,0]
expected: [1,2,3,0,0]
case 2
in: [[1,2],2,9]
expected: [1,2]
case 3
in: [[1,2],4,-1]
expected: [1,2,-1,-1]
case 4
in: [[],3,0.5]
expected: [0.5,0.5,0.5]
Starter codePython
def series_padding(series, target_length, pad_value):
    # Your code here
    pass

4 test cases · run your code against them in the editor