हिंदी

Try to write a short code to get the above output. Remember to print the relevant headings of the output. Slicing of the DataFrame to get only the marks

Advertisements
Advertisements

प्रश्न

Try to write a short code to get the above output. Remember to print the relevant headings of the output.

Slicing of the DataFrame to get only the marks

  Maths Science S.St Hindi Eng
3 20 17 22 24 19
4 23 15 21 25 15
5 22 18 19 23 13

Average of marks obtained by Zuhaire in all Unit Tests

3 20.4
4 19.8
5 19.0
dtype float64
कोड लेखन
Advertisements

उत्तर

import pandas as pd
df = pd.DataFrame
(
     {
    'Name': ['Zuhaire','Zuhaire','Zuhaire'],
    'UT': [1,2,3],
    'Maths': [20,23,22],
    'Science': [17,15,18],
    'S.St': [22,21,19],
    'Hindi': [24,25,23],
    'Eng': [19,15,13]
     }
)
dfZuhaire = df[df['Name'] == 'Zuhaire']
print("Slicing of the DataFrame to get only the marks")
print(dfZuhaire[['Maths','Science','S.St','Hindi','Eng']])
print("\nAverage of marks obtained by Zuhaire in all Unit Tests")
print(dfZuhaire[['Maths','Science','S.St','Hindi','Eng']].mean(axis=1))
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 3: Data Handling using Pandas - II - Intext Questions [पृष्ठ ७१]

APPEARS IN

एनसीईआरटी Informatics Practices [English] Class 12
अध्याय 3 Data Handling using Pandas - II
Intext Questions | Q 3. | पृष्ठ ७१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×