A First Look: head, info and describe

head, tail and sample show a few of a DataFrame's rows, info lists every column's type and how many values are there (the first hint of missing values), and describe sums up each number column in eight numbers, from count and mean to the quartiles, with include='all' adding the text columns.

Apprentice · Python · Updated

By

After this lesson you can

  • Look at a DataFrame's rows with head, tail and sample, and read info's dtypes and non-null counts to spot missing values
  • Read describe's summary of a number column in plain words, count, mean, std, min, the quartiles and max

Key takeaways

  • head() shows the first five rows, tail() the last, and sample() a few chosen at random, so you see real values before you trust a column.
  • info() lists every column with its dtype and its non-null count. A count lower than the number of rows means values are missing.
  • describe() gives count, mean (the average), std (how far values usually sit from the average), min, the quartiles and max for each number column.
  • The 25% row is the value a quarter of the values are at or below, 50% is the median, the middle value, and 75% is the value three quarters are at or below.
  • describe(include="all") adds the text columns, with how many different values each has, the most common one and how often it appears.

A new dataset lands on your desk: a class project's survey, a month of a shop's sales, a sensor's readings. Before you average or chart anything, you spend a few minutes getting to know it: what the rows look like, what type each column is, whether anything is missing, and what range the numbers cover. Three methods do most of that work, and analysts run them on every table they open.

The example is Sunnyside Farmers Market's sales for the 2026 season, sales.csv: one row for each product a vendor sold on a Saturday, 1,900 rows, with the columns date, vendor_id, product, category, units and price. The market is our own made-up data.

Peek at the rows: head, tail and sample

Load the file with pd.read_csv (pandas is imported as pd, read "p d") and look at the first rows with head(), five unless you ask for more:

import pandas as pd

sales = pd.read_csv("sales.csv")
sales.head()
         date vendor_id    product category  units  price
0  2026-04-04       V01    lettuce  produce   21.0    3.0
1  2026-04-04       V01       kale  produce   18.0    3.5
2  2026-04-04       V01    spinach  produce   21.0    4.0
3  2026-04-04       V02  honey jar    honey   20.0   12.0
4  2026-04-04       V02  honeycomb    honey    4.0   15.0

tail() shows the last rows. The first and last rows are often the oldest and newest, so sample() picks rows at random from anywhere in the table; random_state=1 makes it pick the same rows every time, so your notebook gives the same answer when it runs again:

sales.sample(3, random_state=1)
            date vendor_id        product     category  units  price
1857  2026-10-31       V05      birdhouse       crafts    3.0   30.0
414   2026-05-30       V03  cinnamon roll  baked goods   59.0    4.0
1162  2026-08-15       V12   salad greens      produce   34.0    4.0

info: types and gaps

info() describes every column at once:

sales.info()
<class 'pandas.DataFrame'>
RangeIndex: 1900 entries, 0 to 1899
Data columns (total 6 columns):
 #   Column     Non-Null Count  Dtype
---  ------     --------------  -----
 0   date       1900 non-null   str
 1   vendor_id  1900 non-null   str
 2   product    1900 non-null   str
 3   category   1900 non-null   str
 4   units      1888 non-null   float64
 5   price      1900 non-null   float64
dtypes: float64(2), str(4)
memory usage: 89.2 KB

Read it line by line: 1,900 rows; each column's name, its Non-Null Count (how many values are there; "null" means missing), and its dtype. Every column has all 1,900 values except units, with 1,888: twelve vendors never reported how many they sold. That's also why units is float64, numbers with decimals, though they're all whole: in pandas, a number column with gaps is stored as decimals. (In pandas 3, text shows as str; older tutorials show object.)

count() gives the same non-null counts as numbers, so the rows minus the count is how many are missing in each column:

len(sales) - sales.count()
date          0
vendor_id     0
product       0
category      0
units        12
price         0
dtype: int64

describe: the numbers in plain words

describe() sums up each number column. round(2) keeps it to two decimals:

sales.describe().round(2)
         units    price
count  1888.00  1900.00
mean     22.42    10.63
std      19.46    10.65
min       1.00     0.50
25%       8.00     3.25
50%      17.00     7.00
75%      31.00    12.00
max     120.00    45.00

Here's each row for units, in plain words:

  • count: 1,888 values are there (the 12 gaps are left out).
  • mean: the average: a vendor sold about 22 of a product on a Saturday.
  • std: the standard deviation, how far values usually sit from the average. About 19 here: most rows sold within about 19 units of 22, between 3 and 41.
  • min and max: the smallest and largest, 1 and 120.
  • 25%: read "25 percent of the values are at or below this": a quarter of the rows sold 8 units or fewer. These cut points are called quartiles.
  • 50%: half sold 17 or fewer. That's the median, the middle value.
  • 75%: three quarters sold 31 or fewer.

Notice the mean, 22, is well above the median, 17. A few cheap, popular products, such as sweet corn at 75 cents an ear, sell around a hundred on a Saturday and pull the average up; the median stays in the middle. When the two disagree, a few large values are worth a look.

The text columns too: include="all"

describe() skips text columns unless you ask for them:

sales.describe(include="all")
              date vendor_id    product category        units        price
count         1900      1900       1900     1900  1888.000000  1900.000000
unique          31        15         80        5          NaN          NaN
top     2026-09-19       V03  honey jar  produce          NaN          NaN
freq            73       180         60      654          NaN          NaN
mean           NaN       NaN        NaN      NaN    22.416843    10.625395
std            NaN       NaN        NaN      NaN    19.463348    10.645001
min            NaN       NaN        NaN      NaN     1.000000     0.500000
25%            NaN       NaN        NaN      NaN     8.000000     3.250000
50%            NaN       NaN        NaN      NaN    17.000000     7.000000
75%            NaN       NaN        NaN      NaN    31.000000    12.000000
max            NaN       NaN        NaN      NaN   120.000000    45.000000

For text, unique is how many different values there are, top the most common one, and freq how often it appears: 31 Saturdays, 15 vendors, 80 products, and 654 of the rows are produce. NaN, read "not a number", fills the cells where a summary doesn't apply, such as the average of a vendor's id.

Check yourself

2 questions to try on the lesson page.

So what

head, info and describe take a minute and tell you what's in a table, what's missing and what's normal, before any number you report depends on it.

Key terms

Related