[SciPy-User] [SciPy-user] ValueError: arrays must have same number of dimensions
Thu Jun 28 12:00:23 CDT 2012
On Thu, Jun 28, 2012 at 12:49 PM, surfcast23 <email@example.com> wrote:
> Hi sanGuziy,
> That did it. Thank you! can you explain why it worked for future
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`).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User