[Numpy-discussion] Re: What am I missing about concatenate?
Robert Kern
robert.kern at gmail.com
Thu Jun 1 11:43:00 EDT 2006
Christopher Barker wrote:
> I want to take two (2,) arrays and put them together into one (2,2)
> array. I thought one of these would work:
>
>>>> N.concatenate(((1,2),(3,4)),0)
> array([1, 2, 3, 4])
>>>> N.concatenate(((1,2),(3,4)),1)
> array([1, 2, 3, 4])
>
> Is this the best I can do?
>
>>>> N.concatenate(((1,2),(3,4))).reshape(2,2)
> array([[1, 2],
> [3, 4]])
>
> Is it because the arrays I'm putting together are rank-1?
Yes.
Look at vstack() (and also its friends hstack(), dstack() and column_stack() for
completeness).
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list