Q. Given a DataFrame mdf as shown below:


   A B C
0 1 2 3
1 4 5 6

Find out the errors in following statements.


(i) mdf.drop(["Total", "Order"], axis = 1)

(ii) mdf.drop (["A", "D"])

(iii) mdf.drop (["A", "D"], axis = 1)


Answer :-

(i) Axis 1 means columns. There are no columns by the name "Total", and "order" in DataFrame mdf. Hence the error.
(ii) No axis given, which means the default axis 0, which is row. There are no rows in DataFrame mdf with labels as "A" and "D". Hence the error.
(iii) Axis 1 means columns. There are no columns by the name "D" in DataFrame mdf. Hence the error.

Post a Comment

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

Previous Post Next Post