The first table
In short: pd.read_csv loads a CSV file into a table (a DataFrame), and head, shape, info and describe show the rows, the size, the types and the summaries before you compute anything.
Problem
“How many orders do we have?”
The manager sends you orders.csv and asks how many orders there are and what the average is. The temptation is to open the file, write mean() and send back a number.
But you do not know yet what is in the file. Is a row an order, or a line of an order? Are there empty cells? Are the numbers numbers, or text like “1,60 €”? A mean of the wrong column gives a wrong answer that looks perfectly serious.
So analysis starts with a first look: what is in the table, before you compute with it.
The idea
The table: read_csv
CSV is a text file with a table: the first line holds the column names, and every next line is one record, with the values separated by commas. Almost every system gives you one: the shop, the bank, Excel.
pandas is the Python library for tables. pd.read_csv reads the file and returns a DataFrame: a table with column names and a number for every row on the left (that is the index). head() shows the first five rows:
import pandas as pd is everyone’s habit: pandas is written pd. The file orders.csv sits next to the code, together with the other shop tables: products.csv, customers.csv, order_items.csv, categories.csv and reviews.csv.
The last line has no print, and still the table comes out. That is how a notebook (Jupyter), where analysts write, works: the value of the last line is shown by itself.
The idea
How many and what: shape and info
shape is a pair (rows, columns). info() describes every column: how many values it has and of what type:
Read it top to bottom:
- 25 rows, 6 columns. No column is completely empty.
category_idhas 24 values out of 25: one product has no category.- The types:
int64is whole numbers,float64decimals,strtext. The dateadded_atis text: pandas does not recognise a date by itself. We will get to that.
More precisely, if you are curious
The str type is new in pandas 3 (2026). In older versions and in many articles text is object. The meaning is the same: the column holds strings.
The idea
The numbers in short: describe
describe() summarises a numeric column: how many values, the mean (mean), the spread (std), the smallest, the largest and the three quarters (25%, 50%, 75%):
The mean price is €7.04, and 50% (the median, the price in the middle) is €2.80. That is a big gap: a few expensive products (the knives at €39, the pan at €24.90) pull the mean up. Tell the manager that “our product costs €7 on average” and they will picture a different shop.
Whether to use the mean or the median is for the statistics module. For now the rule is: look at both.
See it
Which product has no category
info() said one category is missing. Here is the product:
The gift card is not food and not for the home. The gap is real information, not a mistake in the file. Its stock is 999: a placeholder that means “no limit”. Add up the stock in the warehouse and it will skew the result.
That is what the first look gives you: before the first sum you know what is not what it seems.
Try it
The order lines
How many rows does order_items.csv have, and how many units of a product are on a line on average? Put them in rows and avg_qty.
Solution
import pandas as pd
items = pd.read_csv('order_items.csv')
rows = len(items)
avg_qty = items['quantity'].mean()rows = len(items) (152 rows) and avg_qty = items['quantity'].mean() (about 2.41 units). items.shape is a pair (152, 4), so it does not work for rows. A row here is one product in one order, not the whole order: there are 60 orders.
Exercise
The newest orders
head() has a sibling: tail() shows the last rows. Both take how many rows you want: head(10).
The orders file is sorted by date. Put the last 4 orders in latest.
Solution
import pandas as pd
orders = pd.read_csv('orders.csv')
latest = orders.tail(4)
latestlatest = orders.tail(4): orders 57–60, from 5 to 19 October 2026. Two are new, one is paid and one is shipped. The newest are not delivered yet, so for the question “how much do we deliver” they will skew the numbers unless you set them apart.
More precisely, if you are curious
A file exported from Excel in many European languages uses semicolons between values and a comma in numbers: 1,60. Then it is pd.read_csv('file.csv', sep=';', decimal=','). Text from old programs is sometimes in a regional encoding such as Windows-1251: encoding='cp1251'. An Excel sheet is read directly with pd.read_excel, and a database table with pd.read_sql (see the Databases and SQL course).
Test
Check yourself
Related lessons
Section titled "Related lessons"- Continues in: The NumPy array · Vectorization · Summaries and missing values · Broadcasting: the number, the row and the column
- Tasks on this topic: Welcome