Python inside Excel — =PY()
Use Python in a cell like a formula. Pass ranges, return DataFrames, chart inline, and decide when =PY() is the right tool.
Toolkit 7 lessons ~60 min
This is the headline feature. The =PY() formula lets you write a few lines of Python directly inside an Excel cell and get the result back into the spreadsheet. Cloud-powered, no install required (other than Microsoft 365), and surprisingly powerful.
⚠️ Requires Microsoft 365
Standalone Excel 2019/2021/2024 doesn't include
=PY(). If you don't have 365, you can still read this module for the concepts and use Python in Jupyter for the same outcomes.
Lessons in this module
- =PY() — the first ten formulas · 9 min
Type =PY(, write Python, hit Ctrl+Enter. The basic muscle memory. - The xl() helper — getting Excel data into Python · 8 min
How to reference cells, ranges, and tables from inside =PY(). - Pandas in =PY() — the killer combination · 9 min
Run real pandas operations inside Excel cells. Groupby, pivot, sort, filter. - Charts in =PY() with matplotlib and seaborn · 8 min
Return a chart from a =PY() cell. Lives inside the workbook like an image. - When =PY() is the right tool — and when it isn't · 6 min
A decision guide so you reach for the right hammer. - Twelve =PY() recipes you'll use · 9 min
Copy-paste-ready snippets for the most common Python-in-Excel tasks. - Limits, costs, and security of =PY() · 6 min
What =PY() can't do, where it stores your data, and how it's priced.