Here is what I think you should do with numpy cast:
import numpy
import pandas
rng = numpy.arange(2, 51)
box = pandas.DataFrame(index=rng, columns=rng, data=rng*rng[:, None])
In the case when it is impossible to know all the values ahead of time, you can assign them later:
box = pandas.DataFrame(index=rng, columns=rng)
box.iloc[:, :] = some_other_array
And if you really assign small subsets at a time, you should do:
box.iloc[row_positions, column_positions] = values
or
box.loc[row_labels, column_labels] = values
source
share