Advertisements
Advertisements
Question
Consider The following DataFrame 'mdf'.
Rollno | Name | English | Hindi | Maths | |
0 | 1 | Aditya | 23 | 20 | 28 |
1 | 2 | Balwant | 18 | 1 | 25 |
2 | 3 | Chirag | 27 | 23 | 30 |
3 | 4 | Deepak | 11 | 3 | 7 |
4 | 5 | Eva | 17 | 21 | 24 |
- Write Python statements for the DataFrame 'mdf':
- To display the records of the students having roll numbers 2 and 3.
- To increase the marks of subject Math by 4, for all students.
- Write Python statement to display the Rollno and Name of all students who secured less than 10 marks in Maths.
OR
Write Python statement to display the total marks i.e., sum of marks secured in English, Hindi and Maths for all students.
Short Answer
Solution
-
- mdf.iloc[1:3]
- mdf['Maths']=mdf['Maths']+4
- mdf.loc[:,['roll no','name']][mdf['Maths']<10]
OR
Print(mdf.English + mdf.Hindi + mdf.Maths)
shaalaa.com
Is there an error in this question or solution?