After the previous session, you must be able to create NumPy arrays using existing lists. Once you have loaded the data into an array, NumPy offers a wide range of operations to use over the data.
Let’s now learn how to efficiently operate on NumPy arrays. You can download the associated Jupyter Notebook from the link provided below.
You have now loaded the data in the NumPy array. Now let’s start performing operations over it.
In the example given above, if you had been working with lists, you would need to map a lambda
function (or worse, write a for loop). Whereas with NumPy, you simply multiply the arrays.
Let's now learn how to access the elements of an array. For one-dimensional arrays, indexing, slicing, etc. is similar to Python lists, which means that indexing starts at 0.
To summarise, similar to the lists, you can subset your data through the index and conditions based on your requirements over NumPy arrays too. NumPy also allows you to run operations like max()
, min()
, mean()
, etc. over the data directly.
Let's move to the next segment where you will be solving a few problems on NumPy arrays.