Learn data science and machine learning by building real-world projects on Jovian

# angshu-basu/numpy-array-operations

10 months ago

#### Assignment 2 - Numpy Array Operations

This assignment is part of the course "Data Analysis with Python: Zero to Pandas". The objective of this assignment is to develop a solid understanding of Numpy array operations. In this assignment you will:

1. Pick 5 interesting Numpy array functions by going through the documentation: https://numpy.org/doc/stable/reference/routines.html
2. Run and modify this Jupyter notebook to illustrate their usage (some explanation and 3 examples for each function). Use your imagination to come up with interesting and unique examples.
3. Upload this notebook to your Jovian profile using `jovian.commit` and make a submission here: https://jovian.ml/learn/data-analysis-with-python-zero-to-pandas/assignment/assignment-2-numpy-array-operations
5. (Optional) Check out the notebooks shared by other participants and give feedback & appreciation.

The recommended way to run this notebook is to click the "Run" button at the top of this page, and select "Run on Binder". This will run the notebook on mybinder.org, a free online service for running Jupyter notebooks.

Try to give your notebook a catchy title & subtitle e.g. "All about Numpy array operations", "5 Numpy functions you didn't know you needed", "A beginner's guide to broadcasting in Numpy", "Interesting ways to create Numpy arrays", "Trigonometic functions in Numpy", "How to use Python for Linear Algebra" etc.

NOTE: Remove this block of explanation text before submitting or sharing your notebook online - to make it more presentable.

## Title Here

#### Subtitle Here

Write a short introduction about Numpy and list the chosen functions.

• function 1
• function 2
• function 3
• function 4
• function 5

The recommended way to run this notebook is to click the "Run" button at the top of this page, and select "Run on Binder". This will run the notebook on mybinder.org, a free online service for running Jupyter notebooks.

In [1]:
``!pip install jovian --upgrade -q``
In [2]:
``import jovian``
In [ ]:
``jovian.commit(project='numpy-array-operations')``
```[jovian] Attempting to save notebook.. ```

Let's begin by importing Numpy and listing out the functions covered in this notebook.

In [1]:
``import numpy as np``
In [ ]:
``````# List of functions explained
function1 = np.concatenate  # (change this)
function2 = ???
function3 = ???
function4 = ???
function5 = ???
``````

### Function 1 - np.concatenate (change this)

In [14]:
``````# Example 1 - working (change this)
arr1 = [[1, 2],
[3, 4.]]

arr2 = [[5, 6, 7],
[8, 9, 10]]

np.concatenate((arr1, arr2), axis=1)``````
Out[14]:
``````array([[ 1.,  2.,  5.,  6.,  7.],
[ 3.,  4.,  8.,  9., 10.]])``````

In [4]:
``````# Example 2 - working
???
``````

In [15]:
``````# Example 3 - breaking (to illustrate when it breaks)
arr1 = [[1, 2],
[3, 4.]]

arr2 = [[5, 6, 7],
[8, 9, 10]]

np.concatenate((arr1, arr2), axis=0)``````
```--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-15-3386a3db1c34> in <module> 6 [8, 9, 10]] 7 ----> 8 np.concatenate((arr1, arr2), axis=0) <__array_function__ internals> in concatenate(*args, **kwargs) ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 2 and the array at index 1 has size 3```

Explanation about example (why it breaks and how to fix it)

In [23]:
``jovian.commit()``
```[jovian] Attempting to save notebook.. [jovian] Updating notebook "aakashns/numpy-array-operations" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/aakashns/numpy-array-operations ```
Out[23]:
``'https://jovian.ml/aakashns/numpy-array-operations'``

### Function 2 - ???

In [ ]:
``````# Example 1 - working
???
``````

In [ ]:
``````# Example 2 - working
???
``````

In [ ]:
``````# Example 3 - breaking (to illustrate when it breaks)
???
``````

Explanation about example (why it breaks and how to fix it)

In [32]:
``jovian.commit()``
```[jovian] Attempting to save notebook.. [jovian] Updating notebook "aakashns/numpy-array-operations" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/aakashns/numpy-array-operations ```
Out[32]:
``'https://jovian.ml/aakashns/numpy-array-operations'``

### Function 3 - ???

In [ ]:
``````# Example 1 - working
???
``````

In [ ]:
``````# Example 2 - working
???
``````

In [ ]:
``````# Example 3 - breaking (to illustrate when it breaks)
???
``````

Explanation about example (why it breaks and how to fix it)

In [25]:
``jovian.commit()``
```[jovian] Attempting to save notebook.. [jovian] Updating notebook "aakashns/numpy-array-operations" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/aakashns/numpy-array-operations ```
Out[25]:
``'https://jovian.ml/aakashns/numpy-array-operations'``

### Function 3 - ???

In [ ]:
``````# Example 1 - working
???
``````

In [ ]:
``````# Example 2 - working
???
``````

In [ ]:
``````# Example 3 - breaking (to illustrate when it breaks)
???
``````

Explanation about example (why it breaks and how to fix it)

In [26]:
``jovian.commit()``
```[jovian] Attempting to save notebook.. [jovian] Updating notebook "aakashns/numpy-array-operations" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/aakashns/numpy-array-operations ```
Out[26]:
``'https://jovian.ml/aakashns/numpy-array-operations'``

### Function 4 - ???

In [ ]:
``````# Example 1 - working
???
``````

In [ ]:
``````# Example 2 - working
???
``````

In [ ]:
``````# Example 3 - breaking (to illustrate when it breaks)
???
``````

Explanation about example (why it breaks and how to fix it)

In [27]:
``jovian.commit()``
```[jovian] Attempting to save notebook.. [jovian] Updating notebook "aakashns/numpy-array-operations" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/aakashns/numpy-array-operations ```
Out[27]:
``'https://jovian.ml/aakashns/numpy-array-operations'``

### Function 5 - ???

In [ ]:
``````# Example 1 - working
???
``````

In [ ]:
``````# Example 2 - working
???
``````

In [ ]:
``````# Example 3 - breaking (to illustrate when it breaks)
???
``````

Explanation about example (why it breaks and how to fix it)

In [28]:
``jovian.commit()``
```[jovian] Attempting to save notebook.. [jovian] Updating notebook "aakashns/numpy-array-operations" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/aakashns/numpy-array-operations ```
Out[28]:
``'https://jovian.ml/aakashns/numpy-array-operations'``

### Conclusion

Summarize what was covered in this notebook, and where to go next

``jovian.commit()``
```[jovian] Attempting to save notebook.. [jovian] Updating notebook "aakashns/numpy-array-operations" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/aakashns/numpy-array-operations ```
``'https://jovian.ml/aakashns/numpy-array-operations'``
`` ``