Suppose you want to output the first and last 10 rows of the iris data set.

In R:

data(iris)
head(iris, 10)
tail(iris, 10)

In Python (scikit-learn required to load the iris data set):

import pandas as pd
from sklearn import datasets
iris = pd.DataFrame(datasets.load_iris().data)
iris.head(10)
iris.tail(10)

Now, as previously answered, if your data frame is too large for the display you use in the terminal, a summary is output. To visualize your data in a terminal, you could either expend the terminal or reduce the number of columns to display, as follows.

iris.iloc[:,1:2].head(10)

EDIT. Changed .ix to .iloc. From the pandas documentation,

Starting in 0.20.0, the .ix indexer is deprecated, in favor of the more strict .iloc and .loc indexers.

Answer from essicolo on Stack Overflow
🌐
W3Schools
w3schools.com › python › pandas › ref_df_head.asp
Pandas DataFrame head() Method
A DataFrame with headers and the specified number of rows. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.head.html
pandas.DataFrame.head — pandas 3.0.2 documentation
DataFrame.head(n=5)[source]# Return the first n rows. This function exhibits the same behavior as df[:n], returning the first n rows based on position. It is useful for quickly checking if your object has the right type of data in it. When n is positive, it returns the first n rows.
Discussions

Python equivalent of R's head and tail function - Stack Overflow
I want to preview a Pandas dataframe. I would use head(mymatrix) in R, but I do not know how to do this in Pandas Python. When I type df.head(10) I get... More on stackoverflow.com
🌐 stackoverflow.com
df.head(n) - Why does it exist?
The df.head() function saves you 1 character and the name of it is more intuitive than self.iloc in term of getting the head of the data frame. More on reddit.com
🌐 r/learnpython
3
0
October 22, 2022
pandas - What does !head do in python and NumPy? - Stack Overflow
It has nothing to do with Python or NumPy specifically; that's a feature of ipython to run external programs, in this case, the head utility from the standard suite of *NIX command line utilities. More on stackoverflow.com
🌐 stackoverflow.com
pandas - Easiest way to print the head of a data in python? - Stack Overflow
I'm not defining my array with pandas, I'm using numpy to do it and I would like to know if there is any other way to print the first 5 rows of a data. Using pandas this is how I would do it: print... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-dataframe-series-head-method
Pandas Dataframe/Series.head() method - Python - GeeksforGeeks
July 26, 2025 - The head() method structure and contents of our dataset without printing everything. By default it returns the first five rows but this can be customized to return any number of rows.
🌐
Educative
educative.io › answers › what-are-head-and-tail-functions-in-pandas
What are head and tail functions in pandas?
It is widely used in data analysis and machine learning. The head function in Python displays the first five rows of the dataframe by default. It takes in a single parameter: the number of rows.
🌐
Analytics Vidhya
analyticsvidhya.com › home › head () and tail () functions explained with examples and codes
Head () and Tail () Functions Explained with Examples and Codes
June 11, 2025 - The head() function in pandas displays the top rows of a DataFrame, while the tail() function shows the bottom rows. Both functions are used to get a quick overview of the data’s structure and contents, making them essential tools for data ...
🌐
w3resource
w3resource.com › pandas › dataframe › dataframe-head.php
Pandas DataFrame: head() function - w3resource
The head() function is used to get the first n rows. This function returns the first n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it.
🌐
Programiz
programiz.com › python-programming › pandas › methods › head
Pandas head()
import pandas as pd # create a sample DataFrame data = {'Values': [10, 20, 30, 40, 50, 60, 70]} df = pd.DataFrame(data) # use head() without any argument to get the default number of rows top_rows = df.head() print(top_rows) ... In this example, we used the head() method without any argument, so it returns the default number of rows, which is 5.
Find elsewhere
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › DataFrame › head
Python Pandas DataFrame head() - Preview Rows | Vultr Docs
December 24, 2024 - It provides a quick and easy way to glimpse the beginning of a DataFrame, facilitating a better understanding of the data's structure, content, and distribution at an early stage of data analysis.
🌐
Reddit
reddit.com › r/learnpython › df.head(n) - why does it exist?
r/learnpython on Reddit: df.head(n) - Why does it exist?
October 22, 2022 -

Can somebody please explain why the head() function in pandas exists. Since it only returns self.iloc[:n], why was it implemented in the first place?

I use df.head(n) all the time. But I just looked into the source code an realized that there is no "extra value" that is being added. Just a bunch of kinda redunant lines in the code. Is there a reason why it is not redundant?

Sorry for the nooby question and thanks to all serious replies :)

🌐
DataCamp
campus.datacamp.com › courses › data-manipulation-with-pandas › transforming-dataframes
Inspecting a DataFrame | Python
.head() returns the first few rows (the “head” of the DataFrame). .info() shows information on each of the columns, such as the data type and number of missing values.
🌐
GeeksforGeeks
geeksforgeeks.org › python › select-first-or-last-n-rows-in-a-dataframe-using-head-and-tail-method-in-python-pandas
Select first or last N rows in a Dataframe using head() and tail() method in Python-Pandas - GeeksforGeeks
July 15, 2025 - Syntax: Dataframe.head(n). Parameters: (optional) n is integer value, number of rows to be returned. Return: Dataframe with top n rows . Let's Create a dataframe · Python3 ·
🌐
W3Schools
w3schools.com › python › ref_requests_head.asp
Python Requests head Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training · ❮ Requests Module · Make a HEAD request to a web page, and return the HTTP headers: import requests x = requests.head('https://www.w3schools.com/python/demopage.php') print(x.headers) Run Example » ·
🌐
Initial Commit
initialcommit.com › blog › python-pandas-head
Python Head | Pandas DataFrame: head() Method
The head function is a python Pandas method that can be used on a Pandas DataFrame as well a Pandas Series. The head function returns by default the first 5 rows of the data structure it is called on.
🌐
Pandas
pandas.pydata.org › docs › dev › reference › api › pandas.DataFrame.head.html
pandas documentation - DataFrame.head - PyData |
>>> df.head() animal 0 alligator 1 bee 2 falcon 3 lion 4 monkey · Viewing the first n lines (three in this case) >>> df.head(3) animal 0 alligator 1 bee 2 falcon · For negative values of n · >>> df.head(-3) animal 0 alligator 1 bee 2 falcon 3 lion 4 monkey 5 parrot ·
🌐
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.pandas › api › pyspark.pandas.DataFrame.head.html
pyspark.pandas.DataFrame.head — PySpark 4.1.1 documentation
DataFrame.head(n=5)[source]# Return the first n rows. This function returns the first n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it. Parameters · nint, default 5 · Number of rows to select.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.DataFrame.head.html
pandas.DataFrame.head — pandas 3.0.1 documentation
DataFrame.head(n=5)[source]# Return the first n rows. This function exhibits the same behavior as df[:n], returning the first n rows based on position. It is useful for quickly checking if your object has the right type of data in it. When n is positive, it returns the first n rows.
🌐
Quora
quora.com › What-is-DF-head-in-Python
What is DF head () in Python? - Quora
Answer: The code is from pandas library it means data frame head. Meaning you want to display your data table from the top with a default of 50, but you can soecify numbers in the bracket.