Pandas' version of numpy.resize for efficient matrix resizing
If you want to stay within 'Pandas', I would suggest one of the following:
df.unstack() which would result in shape (len(index2), maxlen * num_columns) following your notation; here columns will be stored as a MultiIndex.
Alternatively, you can use df.to_panel(); Panel is a natural Pandas data structure used for 3 dimensions, as in your case. I believe that the shape should be (num_columns, len(index1), maxlen).
You can then fill any nans with .fillna(0).
I have a dataframe with two indexes. (Both timestamps but thats probably not relevant).
I need to get out a numpy matrix with shape (len(first_index), maxlen, num_columns).
maxlen is some number (likely the max of all of the len(second_index)) or just something simple like 1000. 
I can do this with arr = df.as_matrix(...) and then arr.resize((len(first_index), maxlen, num_columns)). Elements in new rows should be 0 so .resize(...) works well.
Is there a simpler and more efficient way to do this within the dataframe? Numpy works just fine but I need maximum efficiency because I have millions of rows.