M = max(max(x) for x in list(foo.values())) + 1
fooarray = numpy.zeros((N, M))
for key1, row in foo.items():
    for key2, value in row.items():
        fooarray[key1, key2] = value
Преобразование dict в массив в NumPy