Hi - Some help create a short program that uses a pandas DataFrame (solution MUST use a DataFrame) to do the following. Please include comments /notes to explain what is going on. Solution does not need to define functions
two csv files are included (grades01.csv): raw marks of students taking an examination; and a further csv file (rubric01.csv) summarizing the maximum mark available for each of the six questions.
Structure of grades01:
Student ID,Question 1,Question 2,Question 3,Question 4,Question 5,Question 6
205842,6.5,6.5,9.5,5.5,3.5,9.5
……..etc...
Structure of rubric01.csv
Question,Max score
Question 1, 10
……. etc...
task is to write a small program that loads the data into Python and displays some information about the data.
Task details
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice:
percentage_grade = 100 * raw_grade / max_score
where raw_grade is the mark given in the grades file, and max_score is given in the rubric file.
If all questions have the same maximum score (as in rubric01.csv) then sorting by average percentage grade is the same as sorting by sum of scores.
If printing out your DataFrame results in ellipses (...), [especially when testing] try using the to_string() method, e.g.: print(df.to_string())
Output expected (in terms of column headers etc):
Enter grades file: grades01.csv
Enter rubric file: rubric01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 1
Mean
Question 1 x.xx
Question 2 y.xx
Question 3 x.xx
Question 4 6.11
Question 5 6.69
Question 6 6.74
Enter grades file: grades01.csv
Enter rubric file: rubric01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 2
25% Median 75%
Question 1 4.500 7.00 8.500
Question 2 5.000 6.75 8.375
Question 3 5.125 6.00 8.375
Question 4 5.000 6.00 7.375
Question 5 4.625 7.00 8.500
Question 6 5.125 7.00 8.500
Enter grades file: grades01.csv
Enter rubric file: rubric01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 3
Student ID Total
0 205842 41.0
1 280642 44.5
2 289179 46.0
3 264178 33.0
4 215754 38.5
5 219697 37.5
6 288204 43.5
...
Enter grades file: grades01.csv
Enter rubric file: rubric01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 4
Student ID Question 1 Question 2 Question 3 Question 4 Question 5 Question 6
0 205842 65.0 65.0 95.0 55.0 35.0 95.0
1 280642 85.0 95.0 35.0 95.0 40.0 95.0
2 289179 70.0 95.0 90.0 95.0 70.0 40.0
3 264178 90.0 35.0 55.0 50.0 55.0 45.0
4 215754 55.0 95.0 50.0 50.0 40.0 95.0
5 219697 50.0 75.0 80.0 45.0 90.0 35.0
6 288204 40.0 55.0 65.0 95.0 90.0 90.0
...
Enter grades file: grades01.csv
Enter rubric file: rubric01.csv
1. Print question average (mean)
2. Print question average (quantiles)
3. Print student totals
4. Print student percentages
5. Print student ranking
Please enter your choice: 5
Student ID
10 286523
45 291465
18 276254
24 283567
2 289179
30 250254
1 280642
...
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd # import pandas library
# In[2]:
grade_file=input('please enter grade file:') # take input name of the grade file
rubric_file=input('please enter rubric file:') # take input name of the rubric file
# In[3]:
df_grade=pd.read_csv("C:/Users/RV/"+grade_file) # open grade and rubric file
df_rubric=pd.read_csv("C:/Users/RV/"+rubric_file)
# In[5]:
print("1. Print question average (mean) \n2. Print question average (quantiles)\n3. Print student totals\n4. Print student percentages\n5. Print student ranking")
flag=input("Please enter your choice: ")
# In[6]:
df_mean=pd.DataFrame(columns=['Question','Mean'])
if(flag=='1'):
list1=[]
list2=[]
for i in range(1,7):
list1.append('Question '+str(i))
list2.append(df_grade['Question '+str(i)].mean())
df_mean['Question']=list1
df_mean['Mean']=list2
print(df_mean)
# In[7]:
df_quantile=pd.DataFrame(columns=['Question','25%','Median','75%'])
if(flag=='2'):
list1=[]
list2=[]
list3=[]
list4=[]
for i in range(1,7):
list1.append('Question '+str(i))
list2.append(df_grade['Question '+str(i)].quantile(q=0.25))
list3.append(df_grade['Question '+str(i)].quantile(q=0.5))
list4.append(df_grade['Question '+str(i)].quantile(q=0.75))
df_quantile['Question']=list1
df_quantile['25%']=list2
df_quantile['Median']=list3
df_quantile['75%']=list4
print(df_quantile)
# In[8]:
df_sum=pd.DataFrame(columns=['Student ID','sum'])
if(flag=='3'):
list1=[]
for i in range(len(df_grade['Student ID'])):
list1.append(df_grade.iloc[i][1]+df_grade.iloc[i][2]+df_grade.iloc[i][3]+df_grade.iloc[i][4]+df_grade.iloc[i][5])
df_sum['Student ID']=df_grade['Student ID']
df_sum['sum']=list1
print(df_sum)
# In[9]:
import copy
df_per=copy.copy(df_grade)
if(flag=='4'):
df_per.iloc[:,1:]=df_per.iloc[:,1:]*100/10 # as max score of all question is 10
print(df_per)
# In[12]:
df_sort_by_sum=copy.copy(df_sum)
if(flag=='5'):
df_sort_by_sum=df_sort_by_sum.sort_values(by=['sum'],ascending=False) # as all question has same max score in rubric file
print(df_sort_by_sum)
I have make a grade file and rubric file to do the task and here is the result I get.
Output:
1st Run:
please enter grade file:grades01.csv please enter rubric file:rubric01.csv
1. Print question average (mean) 2. Print question average (quantiles) 3. Print student totals 4. Print student percentages 5. Print student ranking Please enter your choice: 1
Question Mean 0 Question 1 6.533333 1 Question 2 6.833333 2 Question 3 7.041667 3 Question 4 6.333333 4 Question 5 5.958333 5 Question 6 8.041667
2nd Run:
please enter grade file:grades01.csv please enter rubric file:rubric01.csv
1. Print question average (mean) 2. Print question average (quantiles) 3. Print student totals 4. Print student percentages 5. Print student ranking Please enter your choice: 2
Question 25% Median 75% 0 Question 1 5.375 6.45 8.125 1 Question 2 5.500 7.00 8.500 2 Question 3 6.250 7.25 8.500 3 Question 4 5.750 6.50 7.000 4 Question 5 5.000 5.50 7.250 5 Question 6 6.750 9.00 9.500
3rd Run:
please enter grade file:grades01.csv please enter rubric file:rubric01.csv
1. Print question average (mean) 2. Print question average (quantiles) 3. Print student totals 4. Print student percentages 5. Print student ranking Please enter your choice: 3
Student ID sum 0 205842 28.5 1 205843 32.5 2 205844 33.5 3 205845 34.5 4 205846 31.5 5 205847 33.5 6 205848 28.0 7 205849 37.0 8 205850 38.0 9 205851 38.0 10 205852 25.0 11 205853 32.4
4th Run:
please enter grade file:grades01.csv please enter rubric file:rubric01.csv
1. Print question average (mean) 2. Print question average (quantiles) 3. Print student totals 4. Print student percentages 5. Print student ranking Please enter your choice: 4
5th Run:
please enter grade file:grades01.csv please enter rubric file:rubric01.csv
1. Print question average (mean) 2. Print question average (quantiles) 3. Print student totals 4. Print student percentages 5. Print student ranking Please enter your choice: 5
Student ID sum 8 205850 38.0 9 205851 38.0 7 205849 37.0 3 205845 34.5 2 205844 33.5 5 205847 33.5 1 205843 32.5 11 205853 32.4 4 205846 31.5 0 205842 28.5 6 205848 28.0 10 205852 25.0
Hi - Some help create a short program that uses a pandas DataFrame (solution MUST use...
22.39 LAB 13 C FALL 2019 Overview Demonstrate your ability to use pandas with functions Description Write a program that reads data from an input file using a DataFrame and displays a subset of data using a method Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format: mpg, cylinders, displacement, horsepower, weight, acceleration, model_year, origin, name 18,9,307,130,3504, 12, 70, usa, chevrolet chevelle malibu 15,8,350,165,3693, 11.5,70, usa, buick skylark...
Lab Exercise #15 Assignment Overview This lab exercise provides practice with Pandas data analysis library. Data Files We provide three comma-separated-value file, scores.csv , college_scorecard.csv, and mpg.csv. The first file is list of a few students and their exam grades. The second file includes data from 1996 through 2016 for all undergraduate degree-granting institutions of higher education. The data about the institution will help the students to make decision about the institution for their higher education such as student completion,...
In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...
using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...
C++ program Write a C++ program to manage a hospital system, the system mainly uses file handling to perform basic operations like how to add, edit, search, and delete record. Write the following functions: 1. hospital_menu: This function will display the following menu and prompt the user to enter her/his option. The system will keep showing the menu repeatedly until the user selects option 'e' from the menu. Arkansas Children Hospital a. Add new patient record b. Search record c....
Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1 to the Office of Registrar at the end of the semester. Display an introductory paragraph for the user then prompt the user to enter a student record (student ID number and five exam-scores – all on one line). The scores will be in the range of 0-100. The sentinel value of -1 will be used to mark the end of data. The instructor has...
Problem statement For this program, you are to implement a simple machine-learning algorithm that uses a rule-based classifier to predict whether or not a particular patient has diabetes. In order to do so, you will need to first train your program, using a provided data set, to recognize a disease. Once a program is capable of doing it, you will run it on new data sets and predict the existence or absence of a disease. While solving this problem, you...
you must implement public class Student by following the instructions as follows exactly. You may reference Chapter 7 for the similar examples to get the ideas and concepts. Each student must have the following 5 attributes (i.e., instance variables): private String studentID ; // student’s ID such as 1 private String lastName ; // student’s last name such as Doe private String firstName ; // student’s first name such as John private double gpa...
c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...
Hi I need some help in C programing class and I doing one of the exercise so that I can get better at coding. Suppose you are asked to design a software that helps an elementary school student learn multiplication and division of one-digit integer numbers. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: 1) Multiplication and 2) Division (quotient). Based...