Ravindra BagaleCourses & study guides मराठी Track your progress

29. Python in Excel

29.1 What Python in Excel Is: Availability and Licensing

Example first. Amir knows pandas from college. His team lives in Excel and nobody wants to install Python. With Python in Excel he types Python straight into a cell, for example df.groupby("City")["Amount"].sum(), and the six city totals appear in the workbook. The code runs in the Microsoft Cloud, so there is nothing to install and colleagues with the same Excel can refresh it.

Python in Excel — in 30 seconds

What: Python in Excel lets you type Python code into a cell with the PY function. The code runs in the Microsoft Cloud with libraries from Anaconda (pandas, NumPy, Matplotlib, seaborn, statsmodels) and the result comes back to the cell.

Why: You get pandas grouping, statistics and charts inside the workbook your team already uses, with no local Python installation, and the results live next to normal Excel formulas.

Tiny example: In a Python cell: df.groupby("City")["Amount"].sum() returns Solapur 1299, Pune 544, Nashik 360 and the other cities from the Orders table.

First look at the data (before → after):

Python in Excel: before and after tables, fictional Blinkit Maharashtra data

Expected result — With Python in Excel

Step What happens
1 Code lives in a cell of the workbook
2 Refreshes with the data
3 Nothing to install
Before table and formula as text

Before — Without Python in Excel

Step Typical work
1 Export the sheet to CSV
2 Open Jupyter, run pandas
3 Copy results back to Excel
4 Repeat next week

Formula / click path

Formulas › Insert Python  (or type =PY and press Tab)
Python code runs in the Microsoft Cloud
Result returns to the cell

Do it step by step:

  1. Check your plan and version (version note below). Python in Excel is not in Excel 2024 or 2021.
  2. Open a workbook and select an empty cell.
  3. Select Formulas › Insert Python. The cell becomes a Python cell and shows a PY icon.
  4. Type 1 + 1 and press Ctrl+Enter to commit (Enter only starts a new line of code).
  5. The cell shows 2. Select it: the formula bar also shows the PY icon.
  6. If you see #BLOCKED! or the command is missing, read the availability table and ask IT.

Version note

Python in Excel is part of Excel for Microsoft 365 (not Excel 2024 or 2021). Business and Enterprise users: Excel for Windows (Current Channel Version 2408 or later, Monthly Enterprise 2408, Semi-Annual Enterprise 2502), Excel on the web, and Excel for Mac (16.96 or later). Family and Personal users: in preview on the web and Windows Current Channel (Mac through the Insider Beta Channel). Education: preview through the Insider programme. Not available on iPad, iPhone or Android. It needs internet access, because the code runs in the Microsoft Cloud. Device-based and shared-computer-activation licences are not supported.

Standard compute, premium compute and the add-on

Feature Included with a qualifying Microsoft 365 subscription Python in Excel add-on licence
Write Python formulas in the grid Yes Yes
Calculation speed Standard compute (plus a limited monthly allowance of faster premium compute) Premium compute
Calculation modes for Python Automatic only Automatic, partial and manual
Libraries, charts, analysis, sharing Yes Yes

When the monthly premium allowance runs out, Excel shows a message and switches to standard compute until the next month. Microsoft says Business and Enterprise users on Windows Current Channel can use Python in Excel at standard speed without a paid licence. Free consumer and perpetual (one-time purchase) licences do not support it.

What is in the box

  • Libraries imported for you: import matplotlib.pyplot as plt, import numpy as np, import pandas as pd, import seaborn as sns, import statsmodels as sm. You can see them in Formulas › Initialization (read-only).
  • More libraries from Anaconda can be imported with a normal import line, for example import scipy. Microsoft recommends putting import lines on the first worksheet.
  • No network, no local files: the code cannot reach the internet or your computer. Data comes from the workbook through xl() or from Power Query (lesson 29.7).

Python in Excel or Power Query or formulas?

Job Best tool Why
Clean and combine imports every week Power Query (Module 10) Recorded steps, refresh with one click
Simple totals and lookups Excel formulas Fast, everyone can read them
Grouping, statistics, regression, custom charts Python in Excel pandas, statsmodels and seaborn in a few lines
Heavy data (hundreds of MB) A real Python setup or a database Python in Excel handles up to 100 MB of data per calculation

Microsoft sources (checked 7 October 2026): Introduction to Python in Excel; Python in Excel availability; Open-source libraries and Python in Excel.

Practice task (try it before you open the answer):

  1. Your company uses Microsoft 365 E3 on Windows, Current Channel. Can you use Python in Excel, and at what speed?
  2. Your cousin has Microsoft 365 Family. What does Microsoft say?
  3. Can you use Python in Excel on an iPad?
Answer
  1. Yes. Business and Enterprise users on Windows Current Channel (Version 2408 or later) can use it at standard compute speed without a paid licence, with a limited monthly allowance of premium compute. The add-on licence gives full premium compute and partial/manual calculation.
  2. It is available in preview for Family and Personal users in Excel on the web and Windows Current Channel.
  3. No. iPad, iPhone and Android can open the workbook, but Python cells show an error when they recalculate.

Ravindra Bagale's Tip

Start with one Python cell next to a formula that gives the same answer. When both agree, your team trusts the Python; when they differ, you learn something.