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

how to fix the merging arrays converts int to decimal

I am need to merge 2 arrays together

so if

a = [] 

and

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

b is array([76522, 82096], dtype=int64)

the merge will be [76522, 82096]

but i am getting this in a form of decimal

array([76522., 82096.])

here is my code

a = np.concatenate((a, b))

how can i merge both arrays with same datatype?

>Solution :

Since a is empty, when it gets converted to a numpy array, it chooses a default dtype=float64. Do the conversion explicitly so you can specify the dtype.

np.concatenate((np.array(a, dtype=np.int64), b))
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