Hello, I have this piece of example code
import random, numpy as np y = [] doc_all = [] # da = np.zeros(2) for i in range(4): docs = range(random.randint(1, 10)) y += [i]*len(docs) doc_all += docs # np.append(da, np.column_stack((docs, y)), axis=0) data = np.array([doc_all, y]).transpose() y and docs are lists that are created in the loop body and all joined together. From these two long lists an array is created at the end. At the end data has a shape like (28, 2). Is there a way I can do this more elegantly using numpy or scipy tricks? I was working on something like the two lines I commented out, but ... Thanks, Florian _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion