Assignment 1-Numpy
Use numpy library to answer the following questions:
1. Add a border (filled with 0's) around an existing array
2. Create a 5X5 matrix with random numbers. Use Numpy library to Normalize the
matrix.
3. Create a random 10x2 matrix representing cartesian coordinates, and convert them to
polar coordinates using Numpy.
4. Extract all the contiguous 3x3 blocks from a random 10x10 matrix.
5. Consider a 16x16 array, Calculate the block-sum (block size is 4x4) of all blocks
using NumPy.
6. Considering a 10x3 matrix, extract rows with unequal values (e.g. [2,2,3]).
7. From the array a, replace all values greater than 30 to 30 and less than 10 to 10.
8. Get the positions of top 5 maximum values in a given array a.
9. Compute the counts of unique values row-wise in a 10X10 array.
10. Find the duplicate entries (2nd occurrence onwards) in the given numpy array and
mark them as True. First time occurrences should be False.
11. Import an image and convert it to a numpy array.
12. Find all the peaks in a 1D numpy array a. Peaks are points surrounded by smaller
values on both sides.
13. Given an array of a non-continuous sequence of dates. Make it a continuous sequence
of dates, by filling in the missing dates.
14. From the given 1d array arr =[0,1,2,…..14], generate a 2d matrix using strides, with a
window length of 4 and strides of 2, like [[0,1,2,3], [2,3,4,5], [4,5,6,7]..].
15. Compute the moving average of window size 3, for the given 1D array.
SID-32 without laptop
Next lab check every practical