Consider a DataFrame 'ResultDF' as follows:
Arnab Ramit Samridhi Riya Mallika Maths 90 92 89 81 94 Science 91 81 91 71 95 Hindi 97 96 88 67 99
Arrange the following commands on the basis of number of values in the output in increasing order:
A. ResultDF.loc['Science']
B. ResultDF.loc[:,'Arnab']
C. ResultDF.loc[['Science', 'Hindi']]
D. ResultDF.loc['Maths'] > 90
Consider a DataFrame 'ResultDF' as follows:
| Arnab | Ramit | Samridhi | Riya | Mallika | |
|---|---|---|---|---|---|
| Maths | 90 | 92 | 89 | 81 | 94 |
| Science | 91 | 81 | 91 | 71 | 95 |
| Hindi | 97 | 96 | 88 | 67 | 99 |
Arrange the following commands on the basis of number of values in the output in increasing order:
A. ResultDF.loc['Science']
B. ResultDF.loc[:,'Arnab']
C. ResultDF.loc[['Science', 'Hindi']]
D. ResultDF.loc['Maths'] > 90
Solution
✅ Correct Option: 3
Count the values each command returns.
| Command | Output | Values |
|---|---|---|
D. ResultDF.loc['Maths'] > 90 | Boolean Series; only Ramit (92) and Mallika (94) are True | 2 |
B. ResultDF.loc[:,'Arnab'] | One column, 3 rows | 3 |
A. ResultDF.loc['Science'] | One row, 5 columns | 5 |
C. ResultDF.loc[['Science', 'Hindi']] | 2 rows x 5 columns | 10 |
The increasing order is D, B, A, C.
loc[row, col] with : selects all rows, so loc[:,'Arnab'] returns a column. A list of labels such as ['Science', 'Hindi'] returns a DataFrame, not a Series.
Related questions:
2026: 29 May Shift 1