To display the 3rd , 4th and 5th columns from the 6th to 9th rows of a dataframe DF , you can write ....
Answers
Answered by
1
Answer:
Explanation:
DF.loc[6:9,3:5]
The answer will not be DF.iloc[6:10,3:6] because iloc uses default index, so the 6th value is at default index 5.
Answered by
2
To fetch the data from the given locations, the following syntax is used.
DF.iloc[6:10, 3:6]
Explanation:
- We can use the loc() and iloc() functions to access columns with Pandas DataFrame.
- The first argument ( : ) signifies the rows we'd like to index, and therefore the second argument (Grades) lets us index the column we would like.
- The semicolon returns all of the rows from the column we tend to specify.
- The same result may also be obtained using the blog function. iloc arguments need integer-value indices rather than string-value names.
- In the iloc function 1st, we specify the range of rows i.e. 6 to 10 as 6:10 then after the comma, we should mention the columns as 3:6.
Hence, the DF.iloc[6:10, 3:6] command will display the 3rd, 4th and 5th columns from the 6th to 9th rows of a data frame DF.
Similar questions