from itertools import zip_longest arr = [[1, 2], [3, 4, 5]] result = [list(inner_arr) for inner_arr in zip(*zip_longest(*arr))] # output: [[1, 2, nan], [3, 4, 5]]
from itertools import zip_longest arr = [[1, 2], [3, 4, 5]] result = [list(inner_arr) for inner_arr in zip(*zip_longest(*arr))] # output: [[1, 2, nan], [3, 4, 5]]