Q. Consider the following Class12.csv file containing the data as given below:
RollNo | Name | Accounts | Maths | BSt | IP | Eco |
---|---|---|---|---|---|---|
10 | Ritu Jain | 88 | 67 | 87 | 97 | 56 |
11 | Mridul Mehta | 67 | 78 | 77 | 87 | 90 |
12 | Divij | 87 | 89 | 78 | 82 | 92 |
13 | Yashvi Verma | 67 | 82.3 | 76.5 | 98.2 | 78.6 |
14 | Deepak Virmani | 56.7 | 76.5 | 88 | 78 | 67 |
15 | Jatin Malik | 76 | 66 | 77 | 87.5 | 67.5 |
(a) Read the CSV file into a data frame df which is stored with tab ("\t") separator.
(b) Write the code to find the total marks (Total_marks) for each student and add it to the newly-created data frame.
(c) Also calculate the percentage obtained by each student under a new column "Average" in the data-frame.
Answer :-
(a) df = pd.read_csv('class12.csv', sep = '\t')
(b) df ['total_marks'] = df.sum(axis = 1)
(c) df ['average'] = (df ['total_marks'] / 15) * 100
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )