Joining lists to an array
![](https://secure.gravatar.com/avatar/c1046cc960f1d4fb1747e51c953eb1db.jpg?s=120&d=mm&r=g)
2 Dec
2013
2 Dec
'13
8:52 a.m.
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
3859
Age (days ago)
3859
Last active (days ago)
0 comments
1 participants
participants (1)
-
Florian Lindner