How To Join Two Arrays In A Tuple Into One Array In Numpy
I have a tuple with two arrays and I want to make it one array: The tuple: (array([['No', 'Yes', 'No', 'No'], ['No', 'Yes', 'No', 'Yes'], ['No', 'No', 'No', 'Yes']],
Solution 1:
Just np.vstack
them
np.vstack(tuple_of_array)
example from my terminal:
>>> import numpy as np
>>> array = np.array # Because I'm lazy and wanted to copy/paste your input ;-)>>> arrays = (array([['No', 'Yes', 'No', 'No'],
... ['No', 'Yes', 'No', 'Yes'],
... ['No', 'No', 'No', 'Yes']], dtype='<U7'),
... array([['Yes', 'No', 'No', 'Yes']], dtype='<U7'))
>>> np.vstack(arrays)
array([[u'No', u'Yes', u'No', u'No'],
[u'No', u'Yes', u'No', u'Yes'],
[u'No', u'No', u'No', u'Yes'],
[u'Yes', u'No', u'No', u'Yes']],
dtype='<U7')
Post a Comment for "How To Join Two Arrays In A Tuple Into One Array In Numpy"