KnowledgeBoat Logo
|

Informatics Practices

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]

Python Pandas

3 Likes

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.

Answered By

2 Likes


Related Questions