Informatics Practices
Identify the correct option to select first four rows and second to fourth columns from a DataFrame 'Data':
- display(Data.iloc[1 : 4, 2 : 4])
- display(Data.iloc[1 : 5, 2 ; 5])
- print(Data.iloc[0 : 4, 1 : 4])
- print(Data.iloc[1 : 4, 2 : 4])
Python Pandas
1 Like
Answer
print(Data.iloc[0 : 4, 1 : 4])
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, print(Data.iloc[0 : 4, 1 : 4]) is correct statement to display first four rows and second to fourth columns from a DataFrame Data.
Answered By
1 Like
Related Questions
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
Identify the correct statement :
- The standard marker for missing data in Pandas is NaN.
- Series act in a way similar to that of an array
- Both (a) and (b)
- None of the above
To delete a column from a DataFrame, you may use …………… statement.
- remove
- del
- drop
- cancel
To delete a row from a DataFrame, you may use …………… statement.
- remove
- del
- drop
- cancel