[SciPy-User] [SciPy-user] ValueError: arrays must have same number of dimensions
Tony Yu
tsyu80@gmail....
Thu Jun 28 12:00:23 CDT 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20120628/908848a0/attachment.html
More information about the SciPy-User
mailing list