Pandas
The standard Python library for tabular data manipulation.
CurrentintermediateGuide only -- no course yet
Overview
Pandas provides the DataFrame, a labeled, spreadsheet-like data structure, plus operations for filtering, grouping, joining, and reshaping tabular data -- the de facto standard for data manipulation in Python, built on top of NumPy.
- What it is
- A Python library providing the DataFrame, a labeled table structure with rich data-manipulation operations.
- Why it's used
- It's dramatically faster and more expressive than manipulating tabular data with plain Python lists and loops.
- Where it fits
- Built on NumPy; typically the first tool reached for once data needs to be loaded, cleaned, and explored.
Core concepts
- DataFrames and Series
- Filtering and selecting
- groupby and aggregation
- Merging/joining data
- Handling missing data
Example
Boolean indexing (df[df["price"] > 5]) filters rows matching a condition -- a pattern that reads close to the SQL WHERE clause it's conceptually similar to.
import pandas as pd
df = pd.DataFrame({"item": ["pen", "book"], "price": [2, 15]})
print(df[df["price"] > 5])Common use cases
- Cleaning and exploring datasets
- Reporting and aggregation
- Preprocessing data before machine learning
Project ideas
- Load a CSV of transactions, clean missing values, and compute monthly totals by category