Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Appending two arrays in Python

I am trying to append two numpy arrays A and J[0] using np.concatenate but there is an error. I also present the expected output.

import numpy as np

A=np.array([ 1,  3,  5,  7,  9, 10, 12, 13, 14, 15, 16, 18, 20, 21, 22, 23])

J=[[4, 6, 8, 11, 17, 19]]
J=np.array(J)
T=np.concatenate(A,J[0],axis=1)

The error is

in <module>
    T=np.concatenate(A,J[0],axis=1)

  File "<__array_function__ internals>", line 4, in concatenate

TypeError: concatenate() got multiple values for argument 'axis'

The expected output is

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

array([ 1,  3,  4, 5,  6, 7,  8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])

>Solution :

T = np.sort(np.concatenate((A, J[0])))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading