Lesson 1 of 16
Why pandas
Welcome to Python for Data Analysis. The star of the show is pandas — the library that turns Python into a data powerhouse. If you've used spreadsheets, pandas is like Excel with superpowers: it handles tables of data — loading, cleaning, filtering, grouping, and analysing them in a few lines of code. This lesson covers why pandas. Let's meet it — live:
Click Run to execute the code.
That table is a DataFrame — pandas' core object, and the thing you'll work with constantly. Run it (pandas loads the first time — a few seconds), then edit the numbers and re-run.
Why pandas is the tool for data analysis
PANDAS = the standard Python library for working with TABULAR DATA (rows + columns, like a
spreadsheet or a database table). It's the workhorse of data analysis in Python.
WHY PANDAS (vs spreadsheets or raw Python):
- HANDLES REAL DATA — load CSV/Excel/database data with one line, then slice, filter, clean, +
analyse tables of thousands/millions of rows. Far beyond a spreadsheet's comfort zone.
- POWERFUL + CONCISE — operations that take many clicks in Excel (filter, group, pivot, join)
are ONE readable line in pandas. Repeatable + fast.
- REPRODUCIBLE — your analysis is CODE: re-run it on new data, share it, version it. No manual
re-clicking. (Spreadsheets are error-prone + hard to audit.)
- INTEGRATES — pandas plugs into the whole Python data stack: numpy (math), matplotlib (charts),
scikit-learn (ML), + more. The foundation of data science in Python.
- AUTOMATES — clean + transform data programmatically; run the same pipeline daily.
THE TWO CORE OBJECTS:
- DataFrame — a 2D TABLE (rows + columns). What you'll use most (a whole dataset).
- Series — a single COLUMN (a 1D labelled array). A DataFrame is a dict of Series.
WHAT YOU'LL LEARN (this course): create/load data, select + filter rows/columns, add + transform
columns, handle missing data, group + aggregate (the powerful part), sort, combine tables
(merge/concat), summarise with statistics, make quick charts, + export results — all runnable,
real pandas.
pandas is the standard Python library for working with tabular data (rows + columns, like a spreadsheet or a database table) — the workhorse of data analysis in Python. Why pandas (vs spreadsheets or raw Python): handles real data (load CSV/Excel/database data with one line, then slice, filter, clean, and analyse tables of thousands/millions of rows); powerful + concise (operations that take many clicks in Excel — filter, group, pivot, join — are one readable line); reproducible (your analysis is code: re-run it on new data, share it, version it); integrates (with numpy, matplotlib, scikit-learn — the foundation of the Python data stack); and automates (clean + transform data programmatically). The two core objects: DataFrame (a 2D table — rows + columns — what you'll use most) and Series (a single column — a 1D labelled array — a DataFrame is a dict of Series). What you'll learn: create/load data, select + filter, add + transform columns, handle missing data, group + aggregate, sort, combine tables, summarise, chart, and export — all runnable, real pandas.
The mistake beginners make
The first mistake is staying in spreadsheets for everything — wrestling huge or repetitive data by hand when pandas does it in seconds, reproducibly; learn pandas for real data work. The second mistake is not understanding DataFrame vs Series — confusing the table (DataFrame) with a single column (Series); a DataFrame is columns of Series. The third mistake is skipping the fundamentals for fancy ML — jumping to machine learning before mastering data handling; most data work is loading/cleaning/exploring (pandas). And not running the code — reading about pandas without doing it; edit and run every example. And fearing the setup — thinking you need a complex install; here it runs live in the browser (and locally it's pip install pandas). Use pandas for real data, learn DataFrame vs Series, master the fundamentals, run the code, and don't fear setup.
Your turn
Your turn
- Run the DataFrame: run the sales example above (pandas loads on first run), then edit the numbers/products and re-run to see the table change - getting hands-on immediately.
- Understand what pandas is: note it's THE Python library for TABULAR data (rows + columns) - like a spreadsheet with superpowers, but reproducible code that scales to huge datasets.
- Learn the two core objects: a DataFrame is a 2D TABLE (the whole dataset); a Series is a single COLUMN (1D). A DataFrame is a collection of Series.
- Inspect a DataFrame: try len(sales) for the row count, list(sales.columns) for the column names, and sales.shape for (rows, columns).
- See why it matters: note that filtering/grouping/joining that take many clicks in Excel are one concise, repeatable line in pandas - and it integrates with the whole Python data stack.
Key points
- pandas = the standard Python library for TABULAR data (rows + columns) — the workhorse of data analysis. import pandas as pd (conventionally 'pd').
- Why pandas: handles REAL data (load + slice/filter/clean/analyse thousands+ of rows — beyond spreadsheets), POWERFUL + CONCISE (one line vs many Excel clicks), REPRODUCIBLE (analysis as code — re-run/share/version), INTEGRATES (numpy/matplotlib/scikit-learn), and AUTOMATES pipelines.
- The two core objects: DATAFRAME (a 2D TABLE — rows + columns — the whole dataset, used most) and SERIES (a single COLUMN — 1D labelled array). A DataFrame is a dict of Series. Build one from a dict: pd.DataFrame({'col': [values], ...}).
- Inspect: len(df) (rows), df.columns (column names), df.shape ((rows, cols)), print(df) (the table).
- The mistakes: staying in spreadsheets for big/repetitive work (use pandas), confusing DataFrame vs Series, skipping fundamentals for fancy ML (most work is load/clean/explore), not running the code, and fearing setup (pip install pandas; here it runs live).
Q&A · 0
Enrol to ask questions and join the discussion.
No questions yet — be the first to ask.