Q:

Write a NumPy program to create to concatenate two given arrays of shape (2, 2) and (2,1)

0

Write a NumPy program to create to concatenate two given arrays of shape (2, 2) and (2,1).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np 
nums1 = np.array([[4.5, 3.5],
                 [5.1, 2.3]])
nums2 = np.array([[1],
                  [2]])
print("Original arrays:")
print(nums1)
print(nums2)
print("\nConcatenating the said two arrays:")
print(np.concatenate((nums1, nums2), axis=1))

Sample Output:

Original arrays:
[[4.5 3.5]
 [5.1 2.3]]
[[1]
 [2]]

Concatenating the said two arrays:
[[4.5 3.5 1. ]
 [5.1 2.3 2. ]]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now