Question: Complete the following coding tasks. Each task should be done in its own code cell. There should be no loop used in any coding cell
Complete the following coding tasks. Each task should be done in its own code cell. There should be no loop used in any coding cell
a. Generate a two-dimensional integer array with the shape of (20,5) and name it data. Fill data with random integers from -100 to 100. Display data at the end.[1 mark]
b. Display the average value of the third column in data [1 mark]
c. Display the average value of the first 5 rows in data [1 mark]
d. Display the average value of the first 3 rows and the 4th column in data. [2 marks]
e. Create a new NumPy array which contains the last 4 elements of the second row of data. Display the new array at the end. [1 mark]
f. Reshape data int to 10 x 10 matrix. Display the matrix at the end. [1 mark]
g. Calculate the std deviation of data [1 mark]
h. Replace the most largest number of each row in data with the average of the corresponding row. Display data at the end. [4 marks]
i. Create a new NumPy array which contains random 2 rows in data. Display the new array at the end. [2 marks]
j. Create a new NumPy array which contains random 3 columns in data . Display the new array at the end. [2 marks]
k. Create a new NumPy array which contains 100 random doubles drawn from a normal (Gaussian) distribution. Display the new array at the end. [2 marks]
l. Conver the data to a Panda Data Frame with the header a e and name it dataframe. Describe the dataframe at the end. [1 mark]
m. Save the dataframe into assign1.xlsx. [1 mark]
n. Save the dataframe into assign1.csv. [1 mark]
o. Replace all the negative numbers in dataframe to 0. Describe the dataframe at the end. [1 mark]
p. Replace all the zeros in the dataframe to 1. Describe the dataframe at the end. [1 mark]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
