Problem 1 (11 points) Part A (2 points) Write the necessary Python code in the next code cell to read the data set in th
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Problem 1 (11 points) Part A (2 points) Write the necessary Python code in the next code cell to read the data set in th
Part B (2 points) Use the dataset made in Part A above and write a function that takes dataset and a random number end as inputs and return a new dataset with the following changes: 1. Multiply the values in cells of columns where it is equal or higher than 0.35, to rid and replace the cell values in columns with the new values, 2. Multiply the values in cells of column s t where it is equal or higher than 0.5, to red and replace the cell values in columns with the new values. In import pandas as pd def multiply dataset (dataset, red): INSERT YOUR CODE FOLLOWING THIS LINE; DO NOT ERASE THIS LINE. return dataset Do not delete this line. dataset readataset() muldataset multiply dataset (dataset, 1.5) print (nuldataset.loc[20, 's']) print (muldataset.loc [20, 'st'])
Part C (7 points) In the next code cell below, complete the function data plotter that will take the Python dataframe object dataset created in Part A as the input and plot a graph of the 5th columns of the data set against the first column (ie, the first column must correspond to the horizontal axis of the graph). The column header of column 1 should be used as the label of the horizontal axis, while the header of the 5th column should be used as the label of the vertical axis. The plot line must be yellow in colour and dashed. The header of the 5th column is also used for the legend, and the legend is located at upper center. In marking this question, partial marks are awarded (although according to a fixed rule), so try to do as much as possible. Important notice Note that the show() command has been added to the second last line of the function data plotter to display your graph. Do not add any show() or plt.show() commands in any other code cell. If you do, you may loose marks In 1: def data plotter(dataset): #INSERT YOUR CODE FOLLOWING # Do not delete or change this line. This Line is used in grading your work. THIS LINE; DO NOT ERASE THIS LINE. ax = gca() show() #Do not delete this tine. # Do not delete this Line. #Do not delete this time. This Line is used in grading your work. This Line is used in grading your work. This Line is used in grading your work. return ax to [] Do not delete or edit this cell, but run it to plot your graph, from matplotlib.pyplot import gca, show dataset readbataset() ax data plotter (dataset) 4X