Look at v before the savetxt:
In [34]: v
Out[34]:
array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[0.0, 0.10000000000000001, 0.20000000000000001, 0.30000000000000004, 0.40000000000000002],
[0, 10, 20]], dtype=object)
In [36]: v.shape
Out[36]: (3,)
It's a 1d, 3 element array that contains your 3 arrays. .T does nothing. savetxt is designed to save a 2d table. You may need to experiment with creating arrays from components like this. The fact that they differ in length is important.
At best savetxt can write 3 lists to the file:
In [39]: np.savetxt('test.txt',v,fmt='%s')
In [40]: cat test.txt
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0.0, 0.10000000000000001, 0.20000000000000001, 0.30000000000000004, 0.40000000000000002]
[0, 10, 20]
What output were you expecting?
==============
zip_longest can create 'columns'. The default fill is None. I can fill with an empty string, but then I have to use the %s fmt.
In [50]: for v in itertools.zip_longest(a,b,c,fillvalue=''):
...: print('%5s, %5s. %5s'%tuple(v))
0, 0.0. 0
1, 0.1. 10
2, 0.2. 20
3, 0.3.
4, 0.4.
5, .
6, .
7, .
8, .
9, .
Or with an intermediate array:
In [51]: arr=np.array(list(itertools.zip_longest(a,b,c,fillvalue='')))
In [52]: arr
Out[52]:
array([['0', '0.0', '0'],
['1', '0.1', '10'],
['2', '0.2', '20'],
['3', '0.3', ''],
['4', '0.4', ''],
['5', '', ''],
['6', '', ''],
['7', '', ''],
['8', '', ''],
['9', '', '']],
dtype='<U32')
In [53]: np.savetxt('test.txt',arr, fmt='%5s',delimiter=',')
In [54]: cat test.txt
0, 0.0, 0
1, 0.1, 10
2, 0.2, 20
3, 0.3,
4, 0.4,
5, ,
6, ,
7, ,
8, ,
9, ,
a,b, andcdon't have the samelen, so v is a "jagged" list, so when you callnp.array(v)it's making an array of objects, each of those objects being a python list. Numpy doesn't support jagged arrays, really. Essentially, you can work with an array of lists, or an array of arrays, but the dtype has to beobject, which pretty much defeats the purpose ofnumpy. Just use Python lists.