head()
noun
say it: “HED” /ˈhɛd/
A pandas method that shows only the first few rows of a table, five unless another number is given.
What does head() do in pandas?
head() gives a DataFrame's or Series' first rows: five unless you ask for another number, such as head(3).
tail() gives the last rows the same way. It's the first look at a table you've loaded, without printing all of it.
import pandas as pd
sales = pd.read_csv("sales.csv")
sales.head(3) # the first 3 of the market's sales
sales.tail() # the last 5
In a sentence
- “She called head() with 3 to keep the notebook short.”
- “head() showed the first five sales, enough to see the columns.”
Level: Apprentice · More Python terms at this level
Updated