Take the following series:
import pandas as pd

s = pd.Series([1, 3, 2, [1, 3, 7, 8], [6, 6, 10, 4], 5])

I want to convert this series into the following array:
np.array([
    [ 1.,  1.,  1.,  1.],
    [ 3.,  3.,  3.,  3.],
    [ 2.,  2.,  2.,  2.],
    [ 1.,  3.,  7.,  8.],
    [ 6.,  6., 10.,  4.],
    [ 5.,  5.,  5.,  5.]
])

Currently, I am using this logic:
import numpy as np
import pandas as pd
from itertools import zip_longest

# Convert series and each element in series into list
ls = list(map(lambda v: v if isinstance(v, list) else [v], s.to_list()))
# Cast list elements to 2d numpy array with longest list element as column number
a = np.array(list(zip_longest(*ls, fillvalue=np.nan))).T
# Convert to DataFrame, apply 'ffill' row-wise and re-convert to numpy array
a = pd.DataFrame(a).fillna(method="ffill", axis=1).values

My solution is not really satisfying me, especially the last line where I convert my array to a DataFrame and then back to an array again. Does anyone know a better alternative? You can assume that all list elements have the same length.

Cast pandas series containing list elements to a 2d numpy array
Assuming all list elements have the same length (as indicated), what about using masks and numpy.repeat?
s2 = pd.to_numeric(s, errors='coerce')
m = s2.isna()

out = np.repeat(s2.to_numpy()[:, None], 4, axis=1)
out[m] = np.array(s[m].tolist())

Output:
array([[ 1,  1,  1,  1],
       [ 3,  3,  3,  3],
       [ 2,  2,  2,  2],
       [ 1,  3,  7,  8],
       [ 6,  6, 10,  4],
       [ 5,  5,  5,  5]])

