Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the assignment Given the file name of a . tsv file read from user input containing student names and the respective course assignment

Here is the assignment
Given the file name of a .tsv file read from user input containing student names and the respective course assignment grades, complete a program that performs the following tasks:
Read the input file as a pandas dataframe.
Output the students' names and grades in descending order of Finals scores.
Output each assignment's max score.
Output the median and average of each assignment's scores.
Output the standard deviation of each assignment's scores.
NOTES:
Steps 3 through 5 should only require one function for each step. Ex. Finding the max of each assignment uses max()
Append .to_string() to the end of the function call in order to silence an extraneous line that occurs at the end of the output.
For steps 3,4, and 5, the functions used will require the parameter numeric_only=True to be passed to specify that only numbers will be calculated (as the input file contains strings for student names).
here is my code
import pandas as pd
file_name = input()
df = pd.read_csv(file_name, delimiter='\t')
sorted_df = df.sort_values(by='Final', ascending=False)
sorted_df.reset_index(drop=True, inplace=True)
print(sorted_df.to_string(index=True))
print("
Max Scores:")
max_scores = df.max(numeric_only=True)
print(max_scores.to_string())
print("
Median Scores:")
median_scores = df.median(numeric_only=True)
print(median_scores.to_string())
print("
Average Scores:")
average_scores = df.mean(numeric_only=True, axis=0)
print(average_scores.to_string())
print("
Standard Deviation:")
std_dev = df.std(numeric_only=True)
print(std_dev.to_string())
HLname Fname Midterm1 Midterm2 Final
0 Bradshaw Reagan 969788
1 Charlton Caius 739480
2 Barrett Edan 704559
3 Stern Brenda 908645
4 Mayo Tyrese 886136
Max Scores:
Midterm196
Midterm297
Final 88
Median Scores:
Midterm188.0
Midterm286.0
Final 59.0
Average Scores:
Midterm183.4
Midterm276.6
Final 61.6
Standard Deviation:
Midterm111.304866
Midterm222.634045
Final 22.210358
butLname Fname Midterm1 Midterm2 Final
1 Bradshaw Reagan 969788
2 Charlton Caius 739480
0 Barrett Edan 704559
4 Stern Brenda 908645
3 Mayo Tyrese 886136
Max Scores:
Midterm196
Midterm297
Final 88
Median Scores:
Midterm188.0
Midterm286.0
Final 59.0
Average Scores:
Midterm183.4
Midterm276.6
Final 61.6
Standard Deviation:
Midterm111.304866
Midterm222.634045
Final 22.210358
Here is my output with the minor error of the numbering

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is a confidence interval?

Answered: 1 week ago