Stop 06 · Python for Data AnalysisTopics · 3/12

Pandas Fundamentals

Part of the Data Analyst Roadmap

In short

Pandas is Excel you can script. Filter, sort and summarise lakhs of rows in one line, and rerun the whole thing next month by pressing a single key.

The core Python library for tabular data analysis — loading, inspecting, filtering and transforming data using a syntax that feels like a more powerful, scriptable Excel.

The jaadu flips through a giant register book with a magnifying glass.

Think of it like this

The school office clerk

The office clerk has every student in one giant register. Ask 'all girls in Class 10 with fees pending' and they flip straight to the answer. Pandas is that clerk for your data, except it never gets tired and finishes in a second.

Watch it happen

Your first five minutes with any dataset

read_csv
head
info
filter
sort

1/5Load the file into a DataFrame. Pandas guesses column types as it reads.

The big ideas

What you need to know

Everything is a DataFrame

Rows and named columns, like a sheet. Most work is transforming one DataFrame into another.

Inspect before you trust

head(), info() and describe() tell you size, types and ranges. Run them on every new file.

Filter with conditions

df[df["amount"] > 1000] keeps matching rows. Combine conditions with & and |, each in brackets.

Chain small steps

Filter, then sort, then pick columns. Small readable steps beat one clever unreadable line.

See it in code

Walk through the code

python
1import pandas as pd2 3df = pd.read_csv("orders.csv")4df.info()5df.describe()6 7big_mumbai = df[(df["city"] == "Mumbai") & (df["amount"] > 1000)]8big_mumbai.sort_values("amount", ascending=False).head(10)

1/4read_csv turns the file into a DataFrame called df.

Load, inspect, filter, sort. The same idea as an Excel filter plus sort, but saved as code you can rerun.

Save yourself the pain

Common mistakes

Oops

Writing df[df.city == "Mumbai" and df.amount > 1000].

Do this instead

Use & instead of and, and wrap each condition in brackets. Python's and doesn't work on whole columns.

Oops

Skipping info() and later finding the amount column is text.

Do this instead

Check dtypes first. If a number column says object, it has stray characters to clean.

Your mission

Explore a real dataset

~30 min

Quick check

Which line correctly keeps orders above ₹500 from Delhi?

Go deeper

  1. 1Load a CSV into a Pandas DataFrame and explore it with .head(), .info(), .describe().
  2. 2Practice filtering rows and selecting columns using Pandas syntax.
  3. 3Compare a Pandas operation to the equivalent Excel or SQL operation to build intuition.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge