Let's begin with the basics of NumPy. There are different ways to create NumPy arrays but the easiest way will be to use something that we are all familiar with, which are lists, and pass it to the
nameofarray = np.array(lists)
Below are some examples. Click on the Run button in each trinket to view the results.
To find out what data types are in an array, you can use
You can edit an element in an array by referring to its index.
myArray = [1 2 3 4 5 6 7]. You can change the first element of
20 by referring to its index (which is
myArray = 20
You can also check the shape of an array (i.e. number of rows and columns) using
1. Create a rank 2 (2D) array that resembles the matrix below.
[[11 12 13 14] [15 16 17 18]]
2. Find out the shape of the above array