Reputation: 11
Imm trying to get an output like array([0,1,2,3,4,5]), but this error keeps popping up. When reading the python documentation for the numpy concatenate method, it claims axis=None will flatten the arrays first, so what am I not understanding?
>>> a = np.array([1,2,3,4,5])
>>> b = np.array([0])
>>> b
array([0])
>>> a
array([1, 2, 3, 4, 5])
>>> np.concatenate(b,a,axis=None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<__array_function__ internals>", line 4, in concatenate
TypeError: concatenate() got multiple values for argument 'axis'
>>>
Upvotes: 1
Views: 2619
Reputation: 4427
You are passing multiple arguments for axis, axis is the optional second argument.
https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html
numpy.concatenate((a1, a2, ...), axis=0, out=None, dtype=None, casting="same_kind")
Join a sequence of arrays along an existing axis.
You would need to invoke like
np.concatenate((b, a), axis=None)
instead of
np.concatenate(b, a, axis=None)
Upvotes: 2