(dataset, padding=0, to_left=True)
return dataset
Pad a dataset (list of list) to the left or the right.
Pad a dataset (list of list) to the left or the right.
Pad a dataset ( list of list ) to the left or the right .
def pad_dataset(dataset, padding=0, to_left=True):
    """ Pad a dataset (list of list) to the left or the right. """
    max_l = max(len(x) for x in dataset)
    dataset = [(x if to_left else []) + [padding] * (max_l - len(x)) + ([] if to_left else x) for x in dataset]
    return dataset
def pad_dataset ( dataset , padding = 0 , to_left = True ) : max_l = max ( len ( x ) for x in dataset ) dataset = [ ( x if to_left else [ ] ) + [ padding ] * ( max_l - len ( x ) ) + ( [ ] if to_left else x ) for x in dataset ] return dataset