Use Python with Copilot in Excel: Clean Data and Forecast

Python with Copilot in Excel: clean data and forecast chart graphic

You can now use Python with Copilot in Excel while you edit a workbook, not just while you chat about it. Ask Copilot to use Python, or let it choose Python when a task needs more than native Excel tools, and it can clean data, run a forecast, or draw a chart β€” then write the results straight back into the file.

Microsoft first described the feature in What’s New in Excel (April 2026). The Microsoft 365 Copilot release notes dated 25 August 2026 (covering 11 to 25 August) then listed Use Python when Editing with Copilot in Excel as available on Windows, Mac, and the web. Copilot features roll out in stages, so your account may not show it yet.

What Python with Copilot does in Edit mode

In Edit mode, Copilot can execute Python for advanced analysis, automation, and data transformation, and write the output into the workbook. Microsoft’s examples include statistics, simulations, visualisations, trend summaries, cleaning data, and charts.

That is different from typing a =PY() formula yourself. You stay in the Copilot pane, describe the result, and Copilot writes and runs the Python as part of the edit. You still need to review what lands on the grid. Microsoft’s Copilot in Excel FAQ says Copilot can make mistakes, and that editing only works when Calculation Options are set to Automatic.

Use Plan mode for multi-step or high-stakes work so you can approve the approach before the file changes. Chat mode answers questions without editing the workbook.

Requirements and caveats

You need a Copilot-eligible Excel experience and access to Python in Excel. Confirm both on your own account first.

RequirementDetails
Copilot licencePersonal or Family with AI credits, Microsoft 365 Premium, a commercial Copilot plan, or a Copilot Chat-eligible business or enterprise plan. Tenant settings can still block it.
PlatformsWindows, Mac, and Excel for the web (25 August 2026 release notes). Python in Excel is not available on iPad, iPhone, or Android.
Python in ExcelA qualifying paid Microsoft 365 licence with desktop apps, internet access, and connected experiences. Not supported on device-based or shared-computer licences. Family and Personal access is still a preview on some platforms.
LimitsMonthly premium Python compute, then slower standard compute. Copilot editing needs Calculation Options set to Automatic.
SecurityPython runs in an isolated Microsoft Cloud container with no network or device access. Microsoft says data is not stored at rest and is not used to train Copilot.

These points are summarised from Microsoft’s Copilot FAQ, Python in Excel availability, and Data security and Python in Excel pages.

How to use Python with Copilot in Excel

Follow Microsoft’s “Try this” flow on the Harbor & Pine sample:

  1. Open the practice workbook in Excel for Windows, Mac, or the web. Keep Calculation Options set to Automatic.
  2. Select the Copilot icon in the lower-right corner. Turn on Allow editing, or switch to Plan mode first if you want to approve the steps.
  3. Paste a prompt that names the sheet, the columns, the output, and the instruction to use Python. The three prompts below are ready to paste.
  4. Watch the reasoning in the pane, then inspect the new sheet, values, charts, or Python cells. Compare the totals with the Solutions sheet.

Sample data for the examples

The practice workbook is a sample file for Harbor & Pine Outfitters. The Practice sheet is the Sales_Raw data named in the prompts: 37 rows (36 genuine orders plus one duplicate) from July to December 2025. Columns are OrderDate, Region, Product (Trail Pack $89, Camp Stove $64), Units, Revenue, and Rep.

The file is messy on purpose:

  • Region values with extra spaces or inconsistent caps: east, EAST, and West .
  • Product names that will not group: trail pack and Camp Stove (a double space).
  • Revenue stored as text on three rows: $4,272, 1,664, and 4717 .
  • One exact duplicate of the 12 July 2025 East Trail Pack order (42 units, $3,738).

After you clean the text, convert Revenue to numbers, and drop the duplicate, you should have 36 unique orders, 1,443 units, and $114,927 in revenue. Use the checkpoints below to check Copilot and the Solutions sheet.

Prompts to try with Python and Copilot

Paste these into Edit with Copilot, or into Plan mode first. They also appear on the Try These Prompts sheet:

Use Python to clean the Sales_Raw data: trim extra spaces, standardise Region to East, Central or West, standardise Product to Trail Pack or Camp Stove, convert Revenue to numbers, and remove duplicate rows. Put the cleaned data on a new sheet called Sales_Clean.

Use Python to build a monthly revenue summary by Region from Sales_Clean for July to December 2025, then forecast January to March 2026 revenue for each region and for the company total. Write the results to a sheet called Forecast and show the method you used.

Use Python to create a line chart of actual versus forecast monthly revenue by region, and add a short commentary on the trend.

Treat Excel’s FORECAST.LINEAR result as a baseline, not the only correct answer β€” Copilot’s Python may use a different model. A linear trend on the six monthly totals gives January 2026 $23,302, February $24,487, and March $25,672. If Copilot is far from that line, ask which method it used.

CheckpointExpected value
Unique orders (duplicate removed)36
Total units1,443
Grand total revenue$114,927
East / Central / West$37,569 / $34,281 / $43,077
Jul–Dec 2025 monthly totals07 $16,192, 08 $17,377, 09 $18,562, 10 $19,747, 11 $20,932, 12 $22,117
Linear forecast Jan–Mar 2026$23,302 / $24,487 / $25,672

Python with Copilot vs writing Python yourself vs Excel formulas

For a one-off cleanup and forecast, Python with Copilot is the fastest first draft. For a monthly refresh, keep the logic as Excel formulas or as =PY() cells you can edit. The GROUPBY function in Excel can build the regional summary, and the Copilot in Excel clean data skill can fix spaces, duplicates, and text-as-numbers without Python.

ApproachBest forWhat you needWhat you get
Python with CopilotCleanup, stats, forecasts, and charts described in EnglishCopilot, Python in Excel, Automatic calculation, and Windows, Mac, or webNew sheets, values, and charts you can inspect
Write =PY() yourselfRepeatable Python you will edit and refreshPython in Excel and an internet connectionPython cells that you control
Excel formulas (TRIM, VALUE, SUMIFS, FORECAST.LINEAR)A transparent check anyone can openAny modern Excel β€” no Copilot requiredNormal formulas, as on the Solutions sheet

FAQ

Do I need to know Python to use this?

No. You can describe the result in English. You still need to read the reasoning, check the totals, and judge whether the method fits your data.

Does this work on Excel for the web and on Mac?

Yes. The 25 August 2026 release notes list Windows, Mac, and the web. It does not apply on iPhone, iPad, or Android, because Python in Excel is not available there.

Is my workbook data used to train Copilot?

Microsoft says Python in Excel data is not stored at rest in the Microsoft Cloud and is not used to train Copilot, and that the code has no network, device, or account-token access. Still review what Copilot writes into a shared file.

Why will Copilot not edit my workbook?

Typical causes are a missing or blocked Copilot licence, Calculation Options set to Manual, an unsupported file format or SharePoint check-out, or a rollout that has not reached your account.

The practice workbook has the messy Harbor & Pine data, the three prompts above, and Excel formulas that rebuild the cleaned totals and the linear forecast.

Download the practice workbook

The same data as this tutorial, with empty answer cells and a Solutions sheet.

Team Xl in Excel

Team Xl in Excel

Spreadsheet Architect & Educator at Xl in Excel. Sharing advanced formulas, dynamic arrays, and clean data modeling techniques.

Learn More About Team Xl in Excel →

Leave a Reply

Your email address will not be published. Required fields are marked *

Zoom: 100% | UTF-8 | Xl in Excel