[SciPy-User] [SciPy-user] ValueError: arrays must have same number of dimensions

surfcast23 surfcast23@gmail....
Thu Jun 28 12:03:19 CDT 2012


Thanks for the clarification Tony!

Tony Yu-3 wrote:
> 
> On Thu, Jun 28, 2012 at 12:49 PM, surfcast23 <surfcast23@gmail.com> wrote:
> 
>>
>> Hi sanGuziy,
>>
>>  That did it. Thank you! can you explain why it worked for future
>> reference?
>>
>> Khary
>>
> 
> Hi Khary,
> 
> Two points:
> 1) `concatenate` doesn't know which direction you want to concatenate in
> (this is the `axis` argument Jorge metioned)
> 2) `concatenate` expects arrays of the same dimension (in your example, v
> is 1D and k is 2D), so if you're adding rows to an array, those arrays
> must
> have the same number of columns (v had no columns b/c it was an N-array,
> which is different than an N x 1, column array).
> 
> Instead of `concatenate` you could use `vstack`: `np.vstack([v, k])`
> The "v" in `vstack` means "vertical" here; there's also `hstack` and
> `dstack` (horizontal and depth). `vstack` is nice because you don't have
> to
> broadcast your input `v` to a column vector (as you did with
> `concatenate`).
> 
> -Tony
> 
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
> 
> 

-- 
View this message in context: http://old.nabble.com/ValueError%3A-arrays-must-have-same-number-of-dimensions-tp34086886p34087396.html
Sent from the Scipy-User mailing list archive at Nabble.com.



More information about the SciPy-User mailing list