Pandas DataFrame head() method returns top n rows of a DataFrame or Series where n is a user input value. The head() function is used to get the first n rows. It is useful for quickly testing if your object has the right type of data in it. For negative values of n, the head() function returns all rows except the last n rows, equivalent to df[:-n].


DataFrame.head(n=5)  (n=5 is default we can set any value)


The head() method in python contains only one parameter, which is n. It is an optional parameter. By setting it, we fix the number of rows we want from the DataFrame.

#pandas #python

Pandas DataFrame head() Method in Python
20.10 GEEK