On 05/17/2017 06:15 PM, Luis JM Amoreira wrote:
Hi,
If your arrays have shape (300,1) (single column, 300 rows right?) then
M = numpy.hstack((array1, array2)) is an array with shape (300, 2) (300
rows, 2 columns) and M.T is 2 by 300 [shape (2, 300)]. Take an example:

In [11]: import numpy as np

In [12]: a1=np.random.rand(3,1)

In [13]: a1
Out[13]:
array([[ 0.09042866],
        [ 0.63008665],
        [ 0.99106757]])

In [14]: a2=np.random.rand(3,1)

In [15]: np.hstack((a1,a2))
Out[15]:
array([[ 0.09042866,  0.99965848],
        [ 0.63008665,  0.12334957],
        [ 0.99106757,  0.43502637]])

In [16]: np.hstack((a1,a2)).T
Out[16]:
array([[ 0.09042866,  0.63008665,  0.99106757],
        [ 0.99965848,  0.12334957,  0.43502637]])

Hope this helps!
ze


On 05/17/2017 08:50 PM, Stephen P. Molnar wrote:
I'm beginning to think that I don't know how to ask the question as
Google and Stack Overflow have resulted in nothing.  All of the
results seem to deal with integers.

I have a number of single column floating point arrays each containing
300 entries that I want to combine into a n by 300 array where n is
the number of single column arrays.

I have tried zip, np.concatenate etc with only failure.

Thanks in advance.



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Thanks for your reply.

Here's what I get:

Traceback (most recent call last):

  File "<ipython-input-7-5173f5e64beb>", line 1, in <module>

runfile('/home/comp/Apps/Python/Molecular_Transforms/Basic/MolT_app_1.py', wdir='/home/comp/Apps/Python/Molecular_Transforms/Basic')

File "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 880, in runfile
    execfile(filename, namespace)

File "/home/comp/Apps/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

File "/home/comp/Apps/Python/Molecular_Transforms/Basic/MolT_app_1.py", line 289, in <module>
    f.write("\n".join("".join(map(str, x)) for x in (name_I_app)))

File "/home/comp/Apps/Python/Molecular_Transforms/Basic/MolT_app_1.py", line 289, in <genexpr>
    f.write("\n".join("".join(map(str, x)) for x in (name_I_app)))

TypeError: 'numpy.float64' object is not iterable

However, numpy.column_stack works.

Problem solved.

--
Stephen P. Molnar, Ph.D.                Life is a fuzzy set
www.molecular-modeling.net              Stochastic and multivariate
(614)312-7528 (c)
Skype: smolnar1
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to