What Is Pandas? Python's Data Analysis Toolkit
A clear introduction to pandas — what DataFrames and Series are, why analysts and ML engineers live in it, how to install it, and a tiny first end-to-end example.
What you'll learn
- ✓What pandas is and where it fits in the Python data stack
- ✓The two core data structures: Series and DataFrame
- ✓Why analysts, scientists, and ML engineers spend so much time in it
- ✓How to install pandas and load a real CSV file
- ✓A tiny first end-to-end example, with head and describe
Prerequisites
- •What Is Python? — basic Python familiarity helps
- •Comfort with lists and dictionaries
If you’ve ever opened a CSV in Excel, sorted it, filtered it, made a pivot table, and graphed a column — pandas is the Python tool that does all of that programmatically, on datasets Excel would refuse to open. It is the foundation of the Python data ecosystem and the daily driver for data analysts, scientists, and ML engineers.
This post explains what pandas is, the ideas behind it, and walks through your first end-to-end script.
What pandas actually is
Pandas is a Python library for working with tabular data — anything that fits naturally into rows and columns. It was created in 2008 by Wes McKinney at a hedge fund that needed a better way to handle financial time series in Python.
Three things to internalise:
- It is built on top of NumPy, which gives it fast, vectorised numerical operations.
- Its API is heavily inspired by R’s data.frame and SQL, with Python conveniences.
- It is the default Python tool for cleaning, transforming, and exploring tabular data before you do anything else (model it, visualise it, ship it).
If your data has rows and columns, you probably want pandas.
Two core data structures
Pandas has two objects you’ll use constantly.
Series
A Series is a one-dimensional labelled array. Think of it as a single column of a spreadsheet.
import pandas as pd
prices = pd.Series([10.5, 12.0, 9.75, 14.25])
print(prices)
# output:
# 0 10.50
# 1 12.00
# 2 9.75
# 3 14.25
# dtype: float64
The numbers on the left are the index. By default it’s a range; you can replace it with anything meaningful:
prices = pd.Series([10.5, 12.0, 9.75], index=["apple", "banana", "cherry"])
print(prices["banana"])
# output: 12.0
A Series carries a single data type for all its values — floats here, but it could be ints, strings, dates, or booleans.
DataFrame
A DataFrame is a two-dimensional labelled table — rows and columns, like a spreadsheet or a SQL table.
import pandas as pd
data = {
"product": ["apple", "banana", "cherry"],
"price": [10.5, 12.0, 9.75],
"stock": [40, 12, 200],
}
df = pd.DataFrame(data)
print(df)
# output:
# product price stock
# 0 apple 10.50 40
# 1 banana 12.00 12
# 2 cherry 9.75 200
A DataFrame is a collection of Series — each column is a Series, and they all share the same index. That mental model — “rows are aligned columns” — is more accurate than thinking of it as a list of rows.
Every column can have a different data type, which is exactly what real-world data needs.
Why so much industry runs on pandas
A short list of why pandas is everywhere in data work:
- Loading anything.
read_csv,read_json,read_excel,read_parquet,read_sql— pandas reads the formats data actually lives in. - Vectorised speed. Operations on whole columns are compiled C under the hood; a million-row sum takes milliseconds.
- Expressive selection and filtering.
df[df["price"] > 10]reads like SQL but is just Python. - Group-by and aggregation. Pivot tables, group means, rolling windows — one line each.
- Time series tools. Calendar-aware resampling, time zones, business days.
- Plays nice with the ecosystem. NumPy under it, scikit-learn next to it, Matplotlib and Seaborn for charts, Jupyter for notebooks.
- Ubiquity. Every Python data tutorial, course, and Stack Overflow answer uses it. That network effect compounds.
When a Python data role lists “pandas” in the requirements — which is most of them — this is what they mean.
Installing pandas
Pandas is on PyPI. Inside your project’s virtual environment:
pip install pandas
That pulls in NumPy as a dependency. For reading Excel files you may also want:
pip install openpyxl
For Parquet:
pip install pyarrow
If you’re using a notebook environment (Jupyter, Google Colab), pandas is usually pre-installed.
Verify with:
import pandas as pd
print(pd.__version__)
# output: 2.2.2 (or similar)
pd is the universal alias. Use it; everyone else does.
A first end-to-end example
Imagine a CSV file sales.csv:
date,product,units,revenue
2026-01-04,apple,12,18.00
2026-01-04,banana,7,8.40
2026-01-05,apple,15,22.50
2026-01-05,cherry,3,11.25
2026-01-06,banana,11,13.20
A short script that loads it and explores:
import pandas as pd
df = pd.read_csv("sales.csv")
print(df.head())
# output:
# date product units revenue
# 0 2026-01-04 apple 12 18.00
# 1 2026-01-04 banana 7 8.40
# 2 2026-01-05 apple 15 22.50
# 3 2026-01-05 cherry 3 11.25
# 4 2026-01-06 banana 11 13.20
head() shows the first five rows — a quick sanity check that the data loaded as expected.
For a summary of numeric columns:
print(df.describe())
# output:
# units revenue
# count 5.000000 5.000000
# mean 9.600000 14.670000
# std 4.722288 5.789948
# min 3.000000 8.400000
# 25% 7.000000 11.250000
# 50% 11.000000 13.200000
# 75% 12.000000 18.000000
# max 15.000000 22.500000
describe() gives you count, mean, standard deviation, min, max, and quartiles for every numeric column — a one-line overview of the shape of your data.
For the data types and missing-value count:
print(df.info())
# output:
# <class 'pandas.core.frame.DataFrame'>
# RangeIndex: 5 entries, 0 to 4
# Data columns (total 4 columns):
# # Column Non-Null Count Dtype
# --- ------ -------------- -----
# 0 date 5 non-null object
# 1 product 5 non-null object
# 2 units 5 non-null int64
# 3 revenue 5 non-null float64
# dtypes: float64(1), int64(1), object(2)
# memory usage: 288.0 bytes
head, describe, and info are the first three things you run on any new dataset. They tell you what you’re working with before you write any analysis.
Try it yourself. Find a CSV file you have lying around — bank statement export, a sports dataset from Kaggle, your screen-time report. Load it with pd.read_csv, then run head(), info(), and describe(). Notice what each tells you. The five-minute version of this exercise is how every data project starts.
A first transformation
Beyond looking, a tiny taste of what pandas lets you do.
Total revenue per product:
totals = df.groupby("product")["revenue"].sum()
print(totals)
# output:
# product
# apple 40.50
# banana 21.60
# cherry 11.25
# Name: revenue, dtype: float64
That single line is a group-by and a sum. The equivalent in pure Python with dictionaries and for loops is a dozen lines and easy to get wrong.
Filtering rows:
big_sales = df[df["units"] > 10]
print(big_sales)
# output:
# date product units revenue
# 0 2026-01-04 apple 12 18.00
# 2 2026-01-05 apple 15 22.50
# 4 2026-01-06 banana 11 13.20
Adding a derived column:
df["price_per_unit"] = df["revenue"] / df["units"]
print(df.head())
# output:
# date product units revenue price_per_unit
# 0 2026-01-04 apple 12 18.00 1.50
# 1 2026-01-04 banana 7 8.40 1.20
# 2 2026-01-05 apple 15 22.50 1.50
# 3 2026-01-05 cherry 3 11.25 3.75
# 4 2026-01-06 banana 11 13.20 1.20
This is the style of pandas code that fills most data jobs: load, look, filter, group, derive, repeat.
Where pandas fits in the stack
A typical Python data workflow:
- pandas for ingestion, cleaning, exploration, feature engineering.
- NumPy for the numerical operations underneath.
- Matplotlib or Seaborn for plotting.
- scikit-learn when you want a model — see What Is Machine Learning?.
- Jupyter as the interactive environment that ties it together.
In production data pipelines, pandas often hands off to:
- DuckDB or SQL for very large data.
- Polars (a faster, Rust-based DataFrame library with a similar API) when pandas becomes a bottleneck.
- PySpark for genuinely huge datasets.
Pandas remains the right starting point. You can always migrate later; you almost never need to.
Reflection. Most pandas mastery is not about exotic methods — it’s about knowing the dozen verbs (read_csv, head, filter, groupby, merge, sort_values, value_counts, drop_duplicates, fillna, apply, to_csv, plot) so well that you reach for them by reflex. That’s a few days of focused practice, not months.
What pandas is not
- Not a database. It loads data into memory. Datasets larger than your RAM need DuckDB, Spark, or chunked reading.
- Not a stats library. It has basic descriptive stats; for tests and models, use SciPy or statsmodels.
- Not the fastest DataFrame library anymore. Polars and DuckDB beat it on many benchmarks. But pandas is the most universally known.
Recap
You now know:
- Pandas is Python’s standard library for tabular data
- A Series is a labelled 1D array; a DataFrame is a labelled 2D table
- It’s the daily tool for analysts, scientists, and ML engineers
pip install pandas, thenimport pandas as pdread_csv,head,info, anddescribeare your first four moves on any dataset- Pandas sits on NumPy and hands off to plotting, ML, and SQL tools
Next steps
The next post goes deeper into the DataFrame — selecting columns, indexing rows with loc and iloc, filtering, and sorting.
→ Next: Pandas DataFrames: Reading, Selecting, and Filtering
Related: What Is Python?, Python Dictionaries, What Is Machine Learning?.
Questions or feedback? Email codeloomdevv@gmail.com.
Related articles
- Pandas Pandas DataFrames: Reading, Selecting, and Filtering
A practical guide to the daily DataFrame moves — read_csv and read_json, head and info, column selection, loc vs iloc, boolean filtering, sorting, and value_counts.
- Pandas Pandas MultiIndex Tutorial
A practical guide to Pandas MultiIndex: when to use it, how it really works, and the slicing, stacking, and groupby patterns that make hierarchical data manageable.
- Pandas Pandas groupby, merge, and concat
A practical guide to combining and summarising DataFrames — groupby with named aggregations, multi-column aggregates, the four merge styles, and stacking with concat.
- Pandas Pandas Cheat Sheet: 50 Essential Operations
A practical Pandas cheat sheet covering 50 essential DataFrame operations including selection, filtering, grouping, merging, and data cleaning with copy-paste examples.