Javatpoint Logo
Javatpoint Logo

Pandas DataFrame.head()

The head() returns the first n rows for the object based on position. If your object has the right type of data in it, it is useful for quick testing. This method is used for returning top n (by default value 5) rows of a data frame or series.



n: It refers to an integer value that returns the number of rows.


It returns the DataFrame with top n rows.



0        C
1       C++
2       Python

Example 2

We have a csv file "aa.csv" that have the following dataset.

By using the head() in the below example, we showed only top 2 rows from the dataset.

       Name          Hire Date      Salary      Leaves Remaining
0     John Idle        03/15/14     50000.0        10
1     Smith Gilliam    06/01/15     65000.0        8

Next TopicDataFrame.hist()

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA