Fewpal
0 votes
362 views
in Information Technology by (47.4k points)
closed by

Consider the following DataFrame df and answer questions.

rollnonameUT1UT2UT3UT4
1Prerna Singh24242022
2Manish Arora18171922
3Tanish Goel20221824
4Falguni Jain22202420
5Kanika Bhatnagar15201822
6Ramandeep Kaur20152224

(i) Write down the command that will give the following output.

rollno6
nameTanish Goel
UT124
UT224
UT324
UT424
dtype : object

(a) print(df.max) 

(b) print(df.max()) 

(c) print(df.max(axis=1)) 

(d) print(df.max, axis=1)

(ii) The teacher needs to know the marks scored by the student with roll number 4. Help her to identify the correct set of statement/s from the given options :

(a) df1=df[df[‘rollno’]==4]

print(df1)

(b) df1=df[rollno==4]

print(df1)

(c) df1=df[df.rollno=4]

print(df1)

(d) df1=df[df.rollno==4]

print(df1)

(iii) Which of the following statement/s will give the exact number of values in each column of the dataframe?

i. print(df.count())

ii. print(df.count(0))

iii. print(df.count)

iv. print(df.count(axis=’index’))

Choose the correct option:

(a) both (i) and (ii)

(b) only (ii)

(c) (i), (ii) and (iii)

(d) (i), (ii) and (iv)

(iv) Which of the following command will display the column labels of the DataFrame?

(a) print(df.columns())

(b) print(df.column())

(c) print(df.column)

(d) print(df.columns)

(v) Ms. Sharma, the class teacher wants to add a new column, the scores of Grade with the values, ‘A’, ‘B’, ‘A’, ‘A’, ‘B’, ‘A’ ,to the DataFrame. Help her choose the command to do so:

(a) df.column=[’A’,’B’,’A’,’A’,’B’,’A’]

(b) df [‘Grade’]=[’A’,’B’,’A’,’A’,’B’,’A’]

(c) df.loc[‘Grade’]= [’A’,’B’,’A’,’A’,’B’,’A’]

(d) Both (b) and (c) are correct

1 Answer

+1 vote
by (46.2k points)
selected by
 
Best answer

(i) (b) print(df.max())

(ii) (a) df1=df[df[‘rollno’]==4]

print(df1)

(d) df1=df[df.rollno==4]

print(df1)

(iii) (a) both (i) and (ii)

(iv) (d) both (i) and (ii)

(v) (b) df [‘Grade’]=[’A’,’B’,’A’,’A’,’B’,’A’]

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...