In this python numpy program, we will merge two given NumPy arrays of identical shape.
Steps to solve the program
- Import the numpy library as np.
- Create two identical arrays using np.array().
- Merge two given NumPy arrays using np.concatenate().
- Print the output.
import numpy as np
x = np.array([1,2,3])
y = np.array([4,5,6])
print("Original arrays:")
print(x)
print(y)
output = np.concatenate((x, y))
print("\nAfter concatenate:")
print(output)
Output :
Original arrays:
[1 2 3]
[4 5 6]
After concatenate:
[1 2 3 4 5 6]
calculate averages without NaNs along a row.