Append a NumPy array to an empty array using the append
Example 1
Here we are creating an empty array and then appending it to the array.
Python3
import numpy as np l = np.array([]) l = np.append(l, np.array([ 'G' , 'F' , 'G' ])) l = np.append(l, np.array([ 'G' , 'F' , 'G' ])) print (l) |
Output:
['G' 'F' 'G' 'G' 'F' 'G']
Example 2
Here we are creating an empty array and then appending an empty row in it to see if there is any difference.
Python3
import numpy as np l = np.array([]) l = np.append(l, np.array([])) l = np.append(l, np.array([ 'G' , 'F' , 'G' ])) l = np.append(l, np.array([ 'G' , 'F' , 'G' ])) print (l) |
Output:
We can see that there is no difference in output.
['G' 'F' 'G' 'G' 'F' 'G']
Contact Us