HomeCourseModule 08 › Limits, costs, and security of =PY()

Limits, costs, and security of =PY()

Module 08 · Python inside Excel — =PY()6 min readIntermediate

What you'll learn

  • Know what =PY() doesn't support
  • Understand where the code runs
  • Decide what's appropriate to put in a =PY() cell

The runtime model

When a =PY() cell calculates, Excel sends the code and the relevant Excel data to Microsoft's cloud, runs it in a sandboxed Python environment, and sends the result back. Your laptop does almost nothing — most of the work happens on Microsoft Azure.

What's pre-installed

Microsoft pre-installs a curated set of libraries: pandas, NumPy, matplotlib, seaborn, scikit-learn, statsmodels, and a few more. You can't pip install something extra into a =PY() cell — what's there is what's there.

What's not allowed

Calculation order

Python cells are calculated after regular Excel formulas, top-to-bottom, left-to-right by default. If you have one =PY() that depends on another, that's fine — Excel orders them correctly.

Privacy

The data in cells referenced by xl(...) is sent to Microsoft's servers. For most spreadsheet work this is fine; for highly sensitive data, check your organisation's policy. The data is not used to train AI models per Microsoft's published policy at launch — but verify the current policy at support.microsoft.com.

Cost

At launch, basic =PY() usage is included in Microsoft 365. Premium tiers offer faster compute and higher data limits. Check Microsoft's pricing page for the current numbers.

Performance gotchas

Key takeaways

  • =PY() runs in Microsoft's cloud — your data goes through their servers.
  • No network, no local files, no extra libraries inside =PY().
  • For network/file work, use a Jupyter notebook (the rest of this course).

Decide where each runs

Which of these should live in =PY(), and which in a Jupyter script?

  1. Scrape today's exchange rate from a website.
  2. Make a heatmap of last month's sales.
  3. Combine 50 monthly CSVs from a shared drive.
  4. Compute the correlation matrix of a 20-column table sitting in Excel.
📹 Video walkthrough
A video walkthrough of this lesson will be embedded here. Until then, the written walkthrough above mirrors what the video will cover step-for-step.