CBSE Class 12 Informatics Practices Question 83 of 101

Python Pandas — II — Question 7

Back to all questions
7
Question

Question 7

The head() and tail() extract rows or columns from a DataFrame. Explain.

Answer

The head() function in pandas retrieves the top n rows of a DataFrame, where n is an optional argument defaulting to 5 if not provided. It is used with the syntax <DF>.head(). Similarly, the tail() function in pandas fetches the bottom n rows of a DataFrame, where n is also optional and defaults to 5 if not specified. Its syntax is <DF>.tail().