Introduction To NumPy Array: A Review Of It's Fundamental Features (Part- II)
NumPy Operations
Arithmatic
You can easily perform array with array arithmetic, or scalar with array arithmetic. Let's see some examples:
Universal Function
Numpy comes with many universal array functions, which are essentially just mathematical operations you can use to perform the operation across the array. Let's show some common ones:
NumPy Indexing and Selection
A) Bracket Indexing and Selection: The simplest way to pick one or some elements of an array looks very similar to python lists:
Broadcasting
Numpy arrays differ from a normal Python list because of their ability to broadcast:
Now note the changes also occur in our original array!
Indexing a 2D Numpy Array
The general format is arr_2d[row][col] or arr_2d[row,col] I recommend usually using the comma notation for clarity.
Fancy Indexing
Fancy indexing allows you to select entire rows or columns out of order,to show this, let's quickly build out a numpy array:
Selection
Let's briefly go over how to use brackets for selection based off of comparison operators.
Takeaway
NumPy as is pretty fun and interesting if you are a Python lover like me. So, if you are curious and want something new. Then, play around with these stuff and don't forget to read refer the documentation if you feel stuck.
If you are new to the page and haven't read the first blog. Here you can go and check out: