Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ASSIGNMENT  2

The second assignment is only Python. There are three les: Assignment2.ipynb, hous- ing.csv, and unemployment.csv.  Please follow all the instructions, which are repeated here.  When you  are nished,  please  submit the  Python  notebook le  ONLY. Please do not rename the le, but do enter your Student ID (numerical), in the notebook.

(1) Do not delete any cells

(2) Please put code only in cells where it has # YOUR  CODE  HERE

(3) Make sure you give your answers in the cells below the question.

(4) Make sure you follow the naming of the variables according to the instructions.

(5) Remember that unless specified each plot should have a title and axis labels (and a legend there are multiple lines/plots on the same axis).

QUEsT1oN 1

For this rst question, you will generate the random variable X with the code provided. The result is a 200 X 4 matrix, where each row represents a 4 dimensional point.  In the questions below, we refer to coordinates as the 0th, 1st, 2nd, and 3rd coordinates.

a.) Create a gure with 3 X 3 subplots, where the (i, j)-th plot is a scatter plot of the value of the i-th coordinate and the value of (i + j + 1)-th coordinate. So, counting from coordinates from 0, the rst plot is the 0th and the 1st coordinate, the middle plot (middle row, middle column), will be the 1st coordinate and the 3rd coordinate. Note that not all plots will be lled, i.e. some of them will be empty.

b.) Compute the minimum, maximum and average of each row and store them in vari- ables called mn, mx, and avg. Each should be a 200 X 1 vector.

c.) Using Matplotlib, on one axis, plot the following:

● Histograms of the minimum, maximum and average of each row of X

● Each histogram should have 20 bins

● All three histograms are completely visible.

d.) How many rows in X have all coordinates whose absolute value is smaller than 0.6? Store the answer in a variable called numpts. HINT: The NumPy function abs() may be useful.

e.) Does the answer in d.)  agree with what you see in the gures in a.)?  Here I am asking you to interpret the Figure you created in a.)  (the scatter plot of pairs of coordinates) with the answer you obtained in d.).  Does they agree or do they not? Why or why not? (a few sentences are sufficient).

QUEsT1oN 2

a.) Read in the le housing.csv using Pandas into a variable called housing.

b.) Remove all the columns which have undefined values.  After this part, the variable housing should not contain any undefined values.

c.) Draw the normalised histogram of prices which had Normal sales using 50 bins

d.) Create a dataframe called summary with the year as the index and columns for the minimum, maximum, and mean of the sales prices for each year

● the names should be minimum, maximum, and mean

e.) Plot the minimum, maximum and mean.

QUEsTIoN 3

a.) Read the le unemployment.csv into a dataframe called unemp using Pandas

● Remove any column or row which does not correspond to a country or date

● All invalid values should be given a value of 0

● All columns except the date name should be numeric while the date should be of type datetime

b.) Set the index to the Date

c.) Create a line plot corresponding to Canada and Korea using complementary colours (please explicitly make the colours complementary)

d.) Complete the function below which takes in an integer and returns N colours equally spaced in hue (with maximum saturation and value/luminance) as rgb values

e.) Plot the unemployment rates in 2020

● include all countries whose names start with a letter which comes before but not including F

● use the colour function you have just written.