[SciPy-user] Concatenating 1D arrays
Robert Kern
robert.kern at gmail.com
Thu Feb 9 11:06:54 EST 2006
Rudolph van der Merwe wrote:
> On 2/8/06, Robert Kern <robert.kern at gmail.com> wrote:
>
>>x = []
>>y = []
>>
>>while have_more_vectors():
>> x.append(get_column_vector_from_somewhere())
>> y.append(get_row_vector_from_somewhere())
>>
>>x = hstack(x)
>>y = vstack(y)
>
> The problem (as far as I know) is that all vectors (1-D arrays) are
> treated as row vectors in Numpy. So the example for y will work, but
> I'm not sure it will work for x. How do you construct a 1-D column
> vector which can then be appended to a list and finally hstacked?
Okay, I presumed get_column_vector_from_somewhere() actually gave you a column
vector. If it's actually giving you shape-(n,) arrays instead of shape-(n,1), use
x = column_stack(x)
instead.
--
Robert Kern
robert.kern at gmail.com
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the SciPy-User
mailing list