KnowledgeBoat Logo
|

Informatics Practices

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

Python Pandas

4 Likes

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().

Answered By

2 Likes


Related Questions