Page 1 of 1

1) Answer the following about NumPy arrays: a) (5 pts) Given a Python list named Ist I, containing the first 5 odd integ

Posted: Sun May 15, 2022 8:40 am
by answerhappygod
1 Answer The Following About Numpy Arrays A 5 Pts Given A Python List Named Ist I Containing The First 5 Odd Integ 1
1 Answer The Following About Numpy Arrays A 5 Pts Given A Python List Named Ist I Containing The First 5 Odd Integ 1 (48.43 KiB) Viewed 61 times
1) Answer the following about NumPy arrays: a) (5 pts) Given a Python list named Ist I, containing the first 5 odd integers, give a simple code to create a NumPy array, named arrl, of single-precision (4 byte) floats, containing the first 20 odd integers using Ist1 converted to floats, as: 1.0, 3.0 etc. b) (5 pts) Give code to create a 4x5 2-dimensinal NumPy array, named arr2, of integers randomly drawn from the interval [0, 20). c) (6 pts) Assume arr is created as: arr = arrl + arr2 What would be the value of each of the following attributes of the array arr? i) ndim ii) shape iii) size d) (4 pts) Give code to get the last row of array arr2. 2) Give code to: a) (5 pts) create a Pandas Series, sl, of 26 elements containing all the characters a', 'b', .... z'. b) (5 pts) create a Pandas dataFrame, dfl, with two rows, the first one containing the first 26 positive integers, and the second row containing their opposite (negative) counterparts. c) (5 pts) vertically stack sl and dfl. d) (10 pts) horizontally stack sl and dfl. e) (10 pts) Using a universal function (ufunc), give code to return at once the average of each of the two rows of afl.