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
What is the difference between sum and cumulative sum? How do you perform the two on DataFrame ?
Name and explain some cumulative functions provided by Pandas.
Why does Python change the datatype of a column as soon as it stores an empty value (NaN) even though it has all other values stored as integer ?
What do quantile and var() functions do ?