Q. Explain what the following statements are doing? df is the name of a DataFrame.


(i) df.iloc[:5,]

(ii) df.iloc [1:5,]

(iii) df.iloc [5,0]

(iv) df.iloc [1:5,0]

(v) df.iloc [1:5, :5]

(vi) df.iloc [2:7, 1:3]


Answer :-

(i) It will display first 5 rows of DataFrame df.
(ii) It will display Second (which has index as 1) to Fifth row of DataFrame df.
(iii) It will display Sixth row's 1st column value of DataFrame df.
(iv) It will display Second to Fifth rows', first column's values of DataFrame df.
(v) It will display Second to Fifth rows', first 5 columns' values of DataFrame df.
(vi) It will display Third to Seventh rows', 2nd and 3rd columns' values of DataFrame df.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post