Python, from Zero, for AILesson 75 of 89

Module 8 · Numbers in bulk: NumPy, pandas and the vector under every model

pandas: a table with named columns, and the four things to look at first

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 6 of 10 in this chapter

This chapter’s goalLoad a messy CSV into pandas, clean its missing values and types, group and join it into the table a question needs, convert it to a NumPy array of the right shape and dtype, compute cosine similarity between one vector and a hundred thousand in a single vectorised expression, plot the result to a file, and explain from memory layout why the array version runs a hundred times faster than the loop it replaced.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:43Not available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 10Free · no account needed
Lesson steps

What a DataFrame is

Module 5 read CSV files with the csv module, one row at a time as dicts. That is right for streaming and for files whose rows you process independently. When you want to ask questions across rows (averages by group, joins, missing-value counts) you want the whole table in memory as columns, and that is pandas.

Python
import pandas as pd

df = pd.read_csv("orders.csv")

A DataFrame is best understood as a dict of columns, where each column is a NumPy-backed Series with one dtype, and all of them share an index: the row labels, which default to 0, 1, 2. Everything fast in pandas is fast because a column is an array; everything slow is slow because you made it loop over rows.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Divya, your AI tutor

How to cite: Addaly (2026) ‘pandas: a table with named columns, and the four things to look at first’, in Python, from Zero, for AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/python-for-ai/pandas-dataframes (Accessed: 21 November 2026).