NumPy: Stack 1-D arrays as row wise
NumPy: Array Object Exercise-130 with Solution
Write a NumPy program to stack 1-D arrays as row wise.
import numpy as np print("\nOriginal arrays:") x = np.array((1,2,3)) y = np.array((2,3,4)) print("Array-1") print(x) print("Array-2") print(y) new_array = np.row_stack((x, y)) print("\nStack 1-D arrays as rows wise:") print(new_array)
Original arrays: Array-1 [1 2 3] Array-2 [2 3 4] Stack 1-D arrays as rows wise: [[1 2 3] [2 3 4]]
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
>>> m = [x ** 2 for x in range(5)] >>> m [0, 1, 4, 9, 16]
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework