To add elements to your dataset, you can use
np.append(ndarray, elements you want to add, axis)
axis = 0 is row (will be added to the bottom most row)
axis = 1 is column (will be added to right most column)
Let's start with an array called x and add an integer to the end of the array
To add more than 1 element, put your elements in a list and append that list to the array
Let's start with a new array
To add extra row of elements to
axis = 0 to
To add extra column of elements to
axis = 1.
Note that the syntax between adding rows and columns differs slightly. To add elements to columns, you need to add each element between its own square bracket.
Use this array for the following practice:
myArray = np.array([[11,12,13], [14,15,16], [17,18,19]])
1. Add a new row of elements containing 20, 21 and 22
2. Add a new column of elements containing 30, 40 and 50