Informatics Practices
To display the 3rd, 4th and 5th columns from the 6th to 9th rows of a dataframe DF, you can write …………… .
- DF.loc[6:9, 3:5]
- DF.loc[6:10, 3:6]
- DF.iloc[6:10, 3:6]
- 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.
Related Questions
To get the transpose of a dataframe D1, you can write …………… .
- D1.T
- D1.Transpose
- D1.Swap
- All of these
To extract row/column from a dataframe, ………… function may be used.
- row()
- column()
- loc()
- All of these
To change the 5th column's value at 3rd row as 35 in dataframe DF, you can write …………… .
- DF[4, 6] = 35
- DF[3, 5] = 35
- DF.iat[4, 6] = 35
- DF.iat[3, 5] = 35
Which among the following options can be used to create a DataFrame in Pandas ?
- A scalar value
- An ndarray
- A python dict
- All of these