Beginner Guide · Pandas for Data
Pandas Basics Explained in Plain Simple Language
Quick summary — the plain-English version
Pandas is a Python library that lets you work with tables (rows and columns) in code instead of clicks. Think of it as Excel, but programmable, faster, and able to handle millions of rows. You load data into something called a DataFrame (a table in memory), clean it, filter it, group it, and save the result. That's it — that's Pandas. Below are the exact building blocks, explained without jargon.
SECTION 01What is Pandas, really?
Pandas is a tool for working with tabular data in Python. If you've used Excel before, you already understand most of what Pandas does. The difference: you tell Pandas what to do in code, so you can repeat it, automate it, and scale it.
| In Excel | In Pandas |
|---|---|
| Open a .xlsx file | pd.read_excel() |
| Filter rows with a drop-down | df[df["sales"] > 1000] |
| Build a pivot table | df.groupby("region").sum() |
| Fix blank cells | df.fillna(0) |
| Save as CSV | df.to_csv("output.csv") |
SECTION 02DataFrames and Series — plain English
These two words are the whole vocabulary of Pandas. If you understand them, everything else makes sense.
| Term | Plain English | Example |
|---|---|---|
| DataFrame | A table — rows and columns | A spreadsheet in memory |
| Series | One column of a DataFrame | The "Sales" column alone |
| Index | The row labels (like row numbers) | 0, 1, 2, ... or dates, IDs |
| Column | A labeled vertical set of values | "Price", "Date", "Name" |
| dtype | The type of data in a column | int64, float, object (text), datetime |
import pandas as pd
# A DataFrame from a dictionary
df = pd.DataFrame({
"name": ["Riya", "Amit", "Priya", "Rahul"],
"age": [24, 30, 28, 35],
"city": ["Delhi", "Noida", "Gurugram", "Delhi"],
"salary": [45000, 60000, 55000, 75000],
})
print(df)
# Output:
# name age city salary
# 0 Riya 24 Delhi 45000
# 1 Amit 30 Noida 60000
# 2 Priya 28 Gurugram 55000
# 3 Rahul 35 Delhi 75000
# A Series — one column
ages = df["age"]
print(ages)
# Output:
# 0 24
# 1 30
# 2 28
# 3 35
# Name: age, dtype: int64
What each line does:
import pandas as pd
→ Imports Pandas, nicknames it "pd"
→ You will type "pd." thousands of times
pd.DataFrame({...})
→ Creates a table from a dictionary
→ Keys become column names
→ Values become column data
df["age"]
→ Extracts one column as a Series
→ Has its own index (row labels)
print(df)
→ Shows the table with rows 0, 1, 2, 3
→ Those numbers are the default index
Rule of thumb:
→ DataFrame = the whole table
→ Series = one column
→ Every column IS a Series
SECTION 03Loading data — the first step
Real projects start with an existing file or database. You don't build DataFrames by hand — you load them.
import pandas as pd
# From a CSV file
df = pd.read_csv("sales.csv")
# From Excel
df = pd.read_excel("sales.xlsx", sheet_name="2026")
# From a URL
df = pd.read_csv("https://example.com/data.csv")
# From a database (with SQLAlchemy)
from sqlalchemy import create_engine
engine = create_engine("postgresql://user:pass@host/db")
df = pd.read_sql("SELECT * FROM sales", engine)
# From JSON
df = pd.read_json("data.json")
Always check your data after loading:
df.head() # First 5 rows
df.tail() # Last 5 rows
df.shape # (rows, columns)
df.info() # Column types, missing values
df.describe() # Numeric summary
df.columns # List of column names
Why:
→ You need to know what's in your data
→ You need to spot obvious problems early
→ You need to know column types (text vs number)
Most beginners skip this step.
Then they spend hours debugging why
"revenue" won't add up.
(It's because it was loaded as text.)
df.info() and df.head(). That tells you
what you're working with. Skipping this step is the #1 source of
"why doesn't my math work" bugs.
SECTION 04Cleaning data — the real work
Cleaning usually takes 60–80% of the time in a real project. Data is always messy — missing values, inconsistent formats, wrong types.
| Problem | Pandas solution | Plain meaning |
|---|---|---|
| Missing values | df.dropna() / df.fillna(0) |
Drop or fill empty cells |
| Wrong types | df["price"].astype(float) |
Convert text to numbers |
| Duplicates | df.drop_duplicates() |
Remove repeated rows |
| Bad dates | pd.to_datetime(df["date"]) |
Parse dates from text |
| Whitespace in text | df["name"].str.strip() |
Clean up spaces |
| Inconsistent casing | df["city"].str.lower() |
"DELHI", "delhi" → "delhi" |
import pandas as pd
df = pd.read_csv("messy_sales.csv")
# 1. See what's missing
print(df.isna().sum())
# Output:
# customer_id 0
# amount 15 ← 15 missing amounts
# date 0
# 2. Drop rows with missing critical data
df = df.dropna(subset=["amount"])
# 3. Or fill missing values
df["amount"] = df["amount"].fillna(0)
# 4. Fix column types
df["amount"] = pd.to_numeric(df["amount"], errors="coerce")
# 5. Fix dates
df["date"] = pd.to_datetime(df["date"], errors="coerce")
# 6. Remove duplicates
df = df.drop_duplicates()
# 7. Clean text
df["city"] = df["city"].str.strip().str.lower()
Why each step matters:
isna().sum()
→ Shows you the count of missing per column
→ You cannot clean blindly
dropna(subset=[...])
→ Drops ONLY rows missing that column
→ Safer than dropping any row with any missing value
to_numeric(errors="coerce")
→ Converts text to numbers
→ Bad values become NaN instead of crashing
to_datetime(errors="coerce")
→ Same idea for dates
→ Enables sorting, filtering by date
drop_duplicates()
→ Removes exact repeated rows
→ Common in exported data
str.strip().str.lower()
→ " DELHI " and "delhi" become the same
→ Critical before grouping by city
Golden rule:
Clean data is boring data.
If you skip cleaning, you'll spend
3 hours debugging a "wrong number"
that was actually " DELHI " vs "Delhi ".
SECTION 05Filtering and selecting
Filtering means "show me only the rows that match a condition." This is the Pandas equivalent of Excel's filter drop-downs.
# Rows where sales > 1000
high_sales = df[df["sales"] > 1000]
# Rows where city is Delhi
delhi = df[df["city"] == "Delhi"]
# Multiple conditions (AND)
big_delhi = df[(df["city"] == "Delhi") & (df["sales"] > 1000)]
# OR
either = df[(df["city"] == "Delhi") | (df["city"] == "Noida")]
# Values in a list
cities = df[df["city"].isin(["Delhi", "Noida", "Gurugram"])]
# Rows with dates after 1 Jan 2026
df["date"] = pd.to_datetime(df["date"])
recent = df[df["date"] > "2026-01-01"]
# Select specific columns
just_sales_and_city = df[["sales", "city"]]
What each does:
df[df["sales"] > 1000]
→ Returns only rows where sales is > 1000
→ The inner df["sales"] > 1000 produces True/False
→ The outer df[...] uses that mask
& (AND) Both conditions must be true
| (OR) Either condition is true
~ (NOT) Invert a condition
.isin([...])
→ Short for "is in this list"
→ Much cleaner than chained OR conditions
Specific columns:
df[["sales", "city"]]
→ Returns a DataFrame with only 2 columns
→ Note the double brackets: df[[...]]
Common mistake:
df["sales", "city"] ← WRONG
df[["sales", "city"]] ← CORRECT (double brackets)
Because one bracket accesses one column (returns Series).
Two brackets select multiple columns (returns DataFrame).
SECTION 06Grouping and summarizing
Grouping means "give me totals by category." It's how you turn thousands of rows into a short summary.
# Total sales by city
by_city = df.groupby("city")["sales"].sum()
print(by_city)
# Output:
# city
# Delhi 42000
# Gurugram 38000
# Noida 31000
# Name: sales, dtype: int64
# Multiple aggregations
summary = df.groupby("city").agg({
"sales": ["sum", "mean", "count"],
"profit": "sum",
})
print(summary)
# Group by multiple columns
by_month_city = (
df
.groupby(["month", "city"])["sales"]
.sum()
.reset_index()
)
# Sort by result
top_cities = by_city.sort_values(ascending=False)
Plain English explanation:
groupby("city")
→ "Split the data into groups by city"
→ Like creating separate sheets per city
["sales"].sum()
→ "For each group, add up the sales"
→ Returns one number per group
.agg({...})
→ "Compute several things at once"
→ sum, mean, count, min, max
groupby(["month", "city"])
→ Group by two things at once
→ Rows grouped by (month, city)
.reset_index()
→ Turns the grouped result back into
a normal DataFrame
→ Easier to save or plot
.sort_values(ascending=False)
→ Sort by the values
→ descending=False → highest first
Think of it as:
SPLIT → APPLY → COMBINE
Split rows into groups
Apply a calculation per group
Combine results into a new table
SECTION 07Saving data — the last step
After cleaning and analyzing, you save the result. Usually as a clean CSV or Excel file — or straight into a dashboard.
# Save as CSV (most common)
df.to_csv("clean_sales.csv", index=False)
# Save as Excel
df.to_excel("clean_sales.xlsx", index=False)
# Save to a database
from sqlalchemy import create_engine
engine = create_engine("postgresql://user:pass@host/db")
df.to_sql("clean_sales", engine, if_exists="replace")
# Save as JSON
df.to_json("clean_sales.json", orient="records")
# Just print a preview
print(df.head())
Best practices for saving:
index=False
→ Skip saving the row numbers
→ Otherwise you'll get an extra "Unnamed: 0" column
→ When someone reopens the file, they'll hate you
if_exists="replace"
→ For databases: replace the whole table
→ Other options: "append", "fail"
Filename conventions:
✗ output.csv
✗ final_final.csv
✓ clean_sales_2026-11.csv
✓ monthly_sales_dashboard.csv
Always include the date or version
in the filename. Future-you will thank you.
Before saving:
df.shape # confirm row count is right
df.head() # spot-check first rows
df.dtypes # confirm types are correct
Then save. Never save blindly.
df.shape and
df.head() before saving. It's the 5-second habit that
prevents "wait, this file has 40,000 rows but it should have 4,000."
SECTION 08Test yourself — Pandas basics quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 09Frequently asked questions
What is a DataFrame in simple words?
A DataFrame is a table in memory — rows and columns — that you can manipulate with code. Think of it as a programmable spreadsheet.
What's the difference between a DataFrame and a Series?
A DataFrame is the whole table. A Series is one column of that table. Every column is a Series underneath.
Do I need to know Python to learn Pandas?
Yes — at least basic Python. You need to understand variables, functions, and dictionaries before Pandas makes sense. That's usually 2–4 weeks of Python.
How long does it take to learn Pandas basics?
About 4–6 weeks of focused practice. To become genuinely productive, 2–3 months with real datasets. The basics (DataFrames, loading, filtering, groupby) are much faster — a week or two.
Is Pandas still used in 2026?
Yes. Pandas is still the most widely used Python data library. Alternatives (Polars, DuckDB) exist, but Pandas remains dominant in analytics and ML workflows.
SECTION 10Related reads
Classroom & online · Noida
Learn Pandas with real projects
Our Data Analytics Course covers Python, Pandas, SQL, and Power BI — explained in plain English, with real projects and interview prep.
₹15,500 · full programme- Python + Pandas + SQL + Power BI
- Real projects & portfolio
- Mock interviews & resume help
- Weekday & weekend batches