Numpy, merging multidimensional arrays
This is a quick guide to show different ways you can merge multidimensional arrays using Numpy in python. If you know any other ones, please let me know in the comment section.
1. One dimension examples
Concatenate and hstack work the same way, except that hstack only takes 1 positional argument
output:
array(['0', '1', '2', '3', '4', 'a', 'b', 'c', 'd', 'e'],
dtype='<U11')
output:
array([['0', '1', '2', '3', '4'],
['a', 'b', 'c', 'd', 'e']],
dtype='<U11')
output:
array([[['0', 'a'],
['1', 'b'],
['2', 'c'],
['3', 'd'],
['4', 'e']]],
dtype='<U11')
2. array examples
output:
array([['0', '1'],
['2', '3'],
['4', '5'],
['a', 'b'],
['c', 'd'],
['e', 'f']],
dtype='<U11')
output:
array([['0', '1', 'a', 'b'],
['2', '3', 'c', 'd'],
['4', '5', 'e', 'f']],
dtype='<U11')
output:
array([[['0', '1'],
['2', '3'],
['4', '5']],
[['a', 'b'],
['c', 'd'],
['e', 'f']]],
dtype='<U11')
output:
array([[['0', '1'],
['a', 'b']],
[['2', '3'],
['c', 'd']],
[['4', '5'],
['e', 'f']]],
dtype='<U11')
output:
array([[['0', 'a'],
['1', 'b']],
[['2', 'c'],
['3', 'd']],
[['4', 'e'],
['5', 'f']]],
dtype='<U11')