CBSE Class 12 Informatics Practices Question 68 of 167

Python Pandas — I — Question 33

Back to all questions
33
Question

Question 33

To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe DF, you can write ............... .

  1. DF.loc[6:9, 3:5]
  2. DF.loc[6:10, 3:6]
  3. DF.iloc[6:10, 3:6]
  4. DF.iloc[6:9, 3:5]
Answer

DF.iloc[6:10, 3:6]

Reason — To display subset from dataframe using row and column numeric index/position, iloc is used with syntax <DF object>.iloc[<start row index>:<end row index>, <start col index>:<end col index>]. Therefore, according to this syntax, DF.iloc[6:10, 3:6] is correct slice notation to display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe DF.