When operating with two-dimensional data arrays, there are some common operations, such as the adding of data and variables, that NumPy functions can render easily and quickly.
The most common such operation is the addition of more cases to your array:
- Let's start off by creating an array:
In: import numpy as np dataset = np.arange(10*5).reshape(10,5)
- Now, let's add a single row and a bunch of rows that are to be concatenated after each other:
In: single_line = np.arange(1*5).reshape(1,5) a_few_lines = np.arange(3*5).reshape(3,5)
- We can first try to add a single line:
- All you have to do is provide a tuple containing the vertical array preceding it and the one following it. ...