I have actually the following values, every of i beg your pardon is a scalar of form double: a1, a2, a3, a4, a5.

You are watching: Valueerror: zero-dimensional arrays cannot be concatenated

I tried to concatenate them using Numpy, together follows:

f = np.concatenate((a1,a2,a3,a4,a5))I yet get the complying with error:

ValueError: zero-dimensional arrays can not be concatenatedWhat could I be doing wrong?

Thanks.


*

concatenate transforms each the the items in the list into range (if that isn"t already), and tries to sign up with them:

In <129>: np.concatenate(<1,2,3,4>)...ValueError: zero-dimensional arrays can not be concatenatedhstack takes the added step of: arrs = , making sure they space at the very least 1d:

In <130>: np.hstack(<1,2,3,4>)Out<130>: array(<1, 2, 3, 4>)But the standard means of creating variety from scalars is through np.array, which join the items follow me a new axis:

In <131>: np.array(<1,2,3,4>)Out<131>: array(<1, 2, 3, 4>)Note the np.array of 1 scalar is a 0d array:

In <132>: np.array(1)Out<132>: array(1)In <133>: _.shapeOut<133>: ()If I want to sign up with 4 0d arrays together, how long will certainly that be? 4*0 =0? 4 1d arrays join on their typical axis is 4*1=4; 4 2d arrays (n,m), will certainly be either (4n,m) or (n,4m) relying on the axis.

np.stack likewise works. The does something comparable to:

In <139>: np.concatenate(>)Out<139>: array(<1, 2, 3, 4>)
re-superstructure
monitor
edited january 27 "18 at 3:51
answered jan 27 "18 in ~ 3:39

*

hpauljhpaulj
184k1313 gold badges184184 silver- badges294294 bronze badges
include a comment |

your Answer


many thanks for contributing solution to stack Overflow!

Please be sure to answer the question. Administer details and also share your research!

But avoid

Asking for help, clarification, or responding to various other answers.Making statements based upon opinion; back them increase with references or an individual experience.

To discover more, check out our tips on writing good answers.

See more: Phone Store On Madison And Cicero, 5222 W Madison St, Chicago, Il 60644


Draft saved
Draft discarded

Sign increase or log in


authorize up using Google
authorize up making use of Facebook
authorize up making use of Email and Password
send

Post together a guest


surname
email Required, however never shown


Post together a guest


surname
email

Required, but never shown


short article Your answer Discard

By click “Post your Answer”, girlfriend agree to our terms of service, privacy policy and cookie policy


Not the prize you're looking for? Browse various other questions tagged python arrays numpy concatenation or ask your very own question.


The Overflow Blog
Featured top top Meta
related
1487
How deserve to I concatenate two arrays in Java?
1712
through arrays, why is that the situation that a<5> == 5?
1256
How have the right to I produce a two dimensional variety in JavaScript?
1662
exactly how to merge two arrays in JavaScript and de-duplicate item
1276
how to sort a Multi-dimensional selection by value
330
Concatenating two one-dimensional NumPy arrays
1352
Merge/flatten an array of arrays
0
concatenating numpy arrays from a directory
0
Python ValueError: zero-dimensional arrays can not be concatenated
hot Network concerns an ext hot inquiries

inquiry feed
i ordered it to RSS
inquiry feed To subscribe to this RSS feed, copy and also paste this URL into your RSS reader.


*

lang-py
stack Overflow
assets
firm
stack Exchange Network
site architecture / logo design © 2021 stack Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.9.27.40313


Stack Overflow works finest with JavaScript permitted
*

your privacy

By clicking “Accept every cookies”, friend agree stack Exchange can store cookie on your device and disclose details in accordance with our Cookie Policy.