0Pricing
Data Science Academy · Lesson

Rows, Columns, and the Index

The mental model of a DataFrame.

Rows, Columns, and the Index is a free Data Science Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Data Science Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

A Table You Can Code

A DataFrame is pandas' spreadsheet in code: rows and columns of data you can slice, sort, and compute on instantly. 📊

Two Axes, One Grid

Every DataFrame has two axes: rows run top to bottom, columns run left to right. Together they form one tidy grid of values.

Columns Are the Variables

Each column holds one variable, like price or city, and shares a single data type. Think of a column as one measured thing.

Rows Are the Records

Each row is one record: a customer, a day, a sale. Read a row across and you get the full story of one observation.

Meet the Index

The index is the label down the left side that names every row. By default it counts 0, 1, 2, but it can be anything unique.

df.index

Columns Have Labels Too

The column headers form their own label set, the columns attribute. You select data by these names instead of guessing positions.

df.columns

Shape Tells the Size

The shape attribute returns rows and columns as a pair. shape[0] is your row count, shape[1] is your column count.

df.shape  # (rows, cols)

One Column Is a Series

Pull a single column and pandas hands you a Series: a one-dimensional labeled array. A DataFrame is really a stack of Series.

df["price"]

Set a Meaningful Index

You can promote a column to be the index when it identifies rows, like an order id. It makes lookups clearer and faster.

df.set_index("order_id")

Labels Drive Everything

Pandas aligns and joins data by labels, not row order. That is why a thoughtful index quietly powers most of your analysis.

Reset When You Need To

Need a plain counting index back? reset_index moves the current index into a column and gives you fresh 0-based labels.

df.reset_index()

Quick Check

Time to test the mental model of a DataFrame.

Recap: The DataFrame Map

Rows are records, columns are variables, and the index labels every row. Know this map and the rest of pandas clicks. 🗺️

Frequently asked questions

Is the “Rows, Columns, and the Index” lesson free?

Yes — the full text of “Rows, Columns, and the Index” is free to read here on the web, and the Data Science Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Data Science Academy course, upgrade to CoddyKit PRO.

What will I learn in “Rows, Columns, and the Index”?

The mental model of a DataFrame. You practise Data Science Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Data Science Academy?

No prior experience is required. Data Science Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Rows, Columns, and the Index” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Data Science Academy lesson?

Yes. Every Data Science Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Rows, Columns, and the Index
  2. Build a DataFrame From Scratch
  3. head, info, and describe
  4. Add, Rename, and Drop Columns
← Back to Data Science Academy