Python Pandas for Data Analysis
DataFrames and Series, selecting and filtering, groupby aggregation, merging, dates, pivot tables and common errors, with runnable examples on a small orders dataset.
9 programs
Choose the best training program according to your career.
Improve the performance of your business with our innovative Industrial Training Program.
Read More →
Our instructor-led training classes are designed to make you an expert.
Read More →
Real-life case studies are a great way to demonstrate your practical knowledge.
Read More →
Explore blogs, latest technologies and industry updates with practical examples.
Read More →Browse all available training programs and choose the right one for your career.
Read More →Know more about who we are and what we stand for.
Discover our mission to equip individuals with essential IT skills and industry expertise.
Read More →Learn, practice and plan your career — bilkul free.
Book a free video counselling session and pick the right course for you.
Read More →Download the pandas data analysis guide PDF from Uncodemy: load, clean, group, merge and summarise data with runnable examples.
This page offers Uncodemy's pandas data analysis guide as a PDF download. Pandas is the main Python library for working with tables of data. The guide explains DataFrames and Series, selecting and filtering, groupby aggregation, merging, working with dates, pivot tables and the errors that trip up beginners. Every example uses a small table built in the code so you can run it as is.
Download the guide below. Each download is its own file, and everything in it is also explained on this page.
DataFrames and Series, selecting and filtering, groupby aggregation, merging, dates, pivot tables and common errors, with runnable examples on a small orders dataset.
A short form asks for your details before the download starts. Your details are used only to share study material and course information.
Pandas provides two main structures. A Series is a single labelled column of values. A DataFrame is a table of columns, each a Series, sharing the same row index. Together with a large set of methods they let you load files, select and filter rows, create new columns, group and summarise, combine tables, reshape data and work with dates and text.
For analysts, pandas is the bridge between a spreadsheet and a full programming language: the ideas are familiar from Excel and SQL, but the work is repeatable and scales to bigger files. The examples below build their own small dataset so that nothing external is needed.
A small orders table built in code, with typical inspection methods.
import pandas as pd
orders = pd.DataFrame({
"order_id": [1, 2, 3, 4, 5, 6],
"city": ["Delhi", "Noida", "Delhi", "Pune", "Noida", "Delhi"],
"status": ["done", "done", "cancelled", "done", "done", "done"],
"amount": [500, 320, 150, 800, 260, 410],
"order_date": pd.to_datetime(["2026-08-03", "2026-08-15", "2026-08-20",
"2026-09-02", "2026-09-10", "2026-09-18"]),
})
print(orders.shape)
print(orders.dtypes)
print(orders.head(3))
print(orders.describe())
Select columns, filter with conditions and create a calculated column. Combine conditions with & and | and put each in brackets.
done = orders[(orders["status"] == "done") & (orders["amount"] > 300)]
print(done[["order_id", "city", "amount"]])
orders["amount_with_gst"] = (orders["amount"] * 1.18).round(2)
orders["size"] = pd.cut(orders["amount"], bins=[0, 300, 600, 10_000],
labels=["small", "medium", "large"])
print(orders[["order_id", "amount", "size"]])
If you already know SQL, most pandas operations will feel familiar.
| Idea | SQL | pandas |
|---|---|---|
| Choose columns | SELECT a, b | df[['a', 'b']] |
| Filter rows | WHERE x > 5 | df[df['x'] > 5] |
| Group and total | GROUP BY c, SUM(x) | df.groupby('c')['x'].sum() |
| Sort | ORDER BY x DESC | df.sort_values('x', ascending=False) |
| Join | JOIN ... ON | df.merge(other, on='key') |
| Distinct count | COUNT(DISTINCT x) | df['x'].nunique() |
Named aggregation produces clearly labelled result columns.
summary = (orders[orders["status"] == "done"]
.groupby("city")
.agg(orders=("order_id", "count"),
revenue=("amount", "sum"),
avg_order=("amount", "mean"))
.round(1)
.sort_values("revenue", ascending=False))
print(summary)
Extract the month, group by it and compute the monthly total. Resampling is another option for a date index.
orders["month"] = orders["order_date"].dt.to_period("M")
monthly = (orders[orders["status"] == "done"]
.groupby("month")["amount"].sum()
.reset_index())
monthly["change_pct"] = (monthly["amount"].pct_change() * 100).round(1)
print(monthly)
Add a city manager from a second table and build a pivot table of revenue by city and month. Use validate to catch unexpected duplicate keys.
managers = pd.DataFrame({"city": ["Delhi", "Noida", "Pune"],
"manager": ["Asha", "Ravi", "Meera"]})
merged = orders.merge(managers, on="city", how="left", validate="many_to_one")
print(len(orders), len(merged)) # row count should not change
pivot = pd.pivot_table(merged[merged["status"] == "done"],
index="city", columns="month",
values="amount", aggfunc="sum", fill_value=0)
print(pivot)
| Message or symptom | Likely cause | Fix |
|---|---|---|
| KeyError: column | Misspelled or padded column name | Print df.columns; strip spaces |
| ValueError: ambiguous truth value | Used and or or instead of & and | | Use & and | with brackets |
| SettingWithCopyWarning | Assigning to a slice | Use .copy() or .loc |
| Row count grows after merge | Duplicate keys on the right side | Use validate and deduplicate |
| Dates as object dtype | Not parsed | Use pd.to_datetime |
Once these operations feel natural, learn reshaping with melt and pivot, string methods for cleaning, window-style operations with rolling and shift and plotting directly from DataFrames.
Practise by taking a real CSV file and answering five business questions with code, then compare your answers with the same questions solved in SQL.
The biggest change when moving from a spreadsheet or a programming loop to pandas is to think about whole columns at once. To add GST to every amount you do not visit each row; you multiply the column. To flag large orders you compare the whole column with a number and get a True or False value for every row. To total revenue by city you group and sum.
This column-first thinking makes code shorter and faster, and it matches how SQL works. When you catch yourself writing a for loop over rows, stop and ask whether a column operation, a groupby or a merge would do the same job.
| Week | Focus | Exercise |
|---|---|---|
| 1 | Loading, inspecting, selecting | Load a CSV and answer five questions using filters |
| 2 | Groupby and aggregation | Summarise revenue by category and month |
| 3 | Merge and reshape | Combine two tables and build a pivot table |
| 4 | Dates and cleaning | Parse dates, handle missing values and write a short report |
Want to use pandas the way analysts do at work? Explore Uncodemy's Data Analytics course and learn from industry trainers.