Q:

Write a NumPy program to add a new row to an empty numpy array

0

Write a NumPy program to add a new row to an empty numpy array.

All Answers

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

import numpy as np    
arr = np.empty((0,3), int)
print("Empty array:")
print(arr)
arr = np.append(arr, np.array([[10,20,30]]), axis=0)
arr = np.append(arr, np.array([[40,50,60]]), axis=0)
print("After adding two new arrays:")
print(arr)

Sample Output:

Empty array:
[]
After adding two new arrays:
[[10 20 30]
 [40 50 60]]

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