#Python

147 posts

Python Data Analysis #4: Transforming Data — New Columns, Dates, and Missing Values
7 min read

Python Data Analysis #4: Transforming Data — New Columns, Dates, and Missing Values

One post covering the data cleanup phase in pandas: vectorized operations for new columns, the str and dt accessors, what NaN really is, how to decide between dropna and fillna, type conversion with astype, and removing duplicates.

Python Data Analysis #3: Selecting and Filtering — loc, iloc, and Boolean Indexing
7 min read

Python Data Analysis #3: Selecting and Filtering — loc, iloc, and Boolean Indexing

How to pick out just the rows and columns you want in pandas: single vs. double brackets for column selection, the loc/iloc distinction, boolean indexing where a condition becomes a mask, the query method, and the danger that SettingWithCopyWarning is warning you about.

Python Data Analysis #2: Loading Data — CSV, Excel, and First Exploration
7 min read

Python Data Analysis #2: Loading Data — CSV, Excel, and First Exploration

The encoding, sep, and dtype arguments of read_csv and the legacy-codepage trap, sheet selection in read_excel, and the routine of checking your data with head, info, and describe right after loading.

Python Data Analysis #1: Getting Started with pandas — Notebooks and the DataFrame
6 min read

Python Data Analysis #1: Getting Started with pandas — Notebooks and the DataFrame

pandas is the Python library for working with tabular data. We set up a notebook environment with uv, build Series and DataFrame objects by hand, and kick off this seven-part data analysis series.

Python Automation #7: Building Your Own Command — Packaging a CLI with typer and rich
5 min read

Python Automation #7: Building Your Own Command — Packaging a CLI with typer and rich

Closing out the series by bundling the automation scripts into a single CLI with typer, polishing the output with rich, and installing it with uv tool install as a command you can call from anywhere.

Python Automation #6: Scheduling — Making Scripts Run While You Sleep
6 min read

Python Automation #6: Scheduling — Making Scripts Run While You Sleep

How to make a finished automation script run on its own at a fixed time. We compare cron, launchd, Windows Task Scheduler, and APScheduler, keep run records with logging, get notified on failures, and cover GitHub Actions schedules.

Python Automation #5: Reporting Results — Email, Slack, and Discord Notifications
6 min read

Python Automation #5: Reporting Results — Email, Slack, and Discord Notifications

The last piece of automation is reporting. Send Slack and Discord notifications with a single httpx POST, email Excel attachments with smtplib, and keep tokens out of your code with a .env file.

Advanced typing — Variance, ParamSpec, Self, overload
10 min read

Advanced typing — Variance, ParamSpec, Self, overload

The next step from intermediate typing — covariance/contravariance, ParamSpec and Concatenate, Self, TypeGuard/TypeIs, and @overload.

Appendix A — Moving old Python code to the modern style
4 min read

Appendix A — Moving old Python code to the modern style

A step-by-step guide for moving 2017-era Python code (% strings, has_key, type() comparison, etc.) to modern Python. So readers of the old 21-part Python basics tutorial can continue naturally into this book.

Async and background jobs
8 min read

Async and background jobs

When to use async routes, BackgroundTasks for post-response work, the boundary where external queues (Celery, ARQ) start to be needed, and how to safely mix in sync libraries.

Async in depth — event loop, gather/wait, async generator
9 min read

Async in depth — event loop, gather/wait, async generator

The next step from the intermediate intro — how the event loop actually works, the difference between Future and Task, gather vs wait, async generators and async iteration.

Asyncio intro
9 min read

Asyncio intro

What async/await means, the event loop, asyncio.gather and TaskGroup, and mixing with sync code — your first steps into asyncio in one place.