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

Join 2 1-dimensional numpy string arrays into a larger 2 dimensional array

At the current moment, I am trying to combine an array of titles with a corresponding ID number (in String format) into a larger array as such:

import numpy as np
titles = np.array(['title1', 'title2', 'title3'])
IDs = np.array(['1543', '1231', '1551'])

newOutput = combinepseudocode(titles, IDs)
newOutput = [['title1', '1543'], ['title2', '1231'], ['title3', '1551']]

When looking for answers online, I’ve only come across posts suggesting the np.char.join() or np.concatenate() functions, but the former joins the strings in 2 arrays into a single string, while np.concatenate() only works on integer scalar arrays.

Any help would be appreciated. Thanks!

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

>Solution :

np.column_stack((titles, IDs))
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