Python in Excel is now a thing! Python is now a peer of the Excel formula language and you can mix both languages seamlessly in the Excel grid. Python runs on Azure and is powered by the @anacondainc Python distribution.
This was a multi-year collaboration between the Python team in Developer Division and the Excel team. It was a privilege of a lifetime to work daily with @gvanrossum @ahejlsberg @keyurp32 @jjmcdaid @zooba @iritkatriel @oterocarlos and a few other folks who don't use this site.
techcommunity.microsoft.com/…
54
385
2,018
602,045
For folks who like videos, there is now content up on YouTube as well so you can see it in action.
piped.video/watch?v=-_1IaUjO…
2
11
91
15,789
The opening of this video is 🔥🔥🔥 piped.video/watch?v=FbBXtqtR…
1
5
39
12,639
Bringing the worlds of Python and Excel together was no easy feat. Both have existed and evolved independently for over 3 decades(!)
One of the key pieces of integration is the Python xl() function. You can pass a range to it, e.g., xl("A1:Z42") and it will return a Pandas DataFrame as the result. This makes it natural and familiar to work with rectangular data from Excel in Python. For more details see the docs: support.microsoft.com/en-us/…
1
3
32
10,402
One thing that you might notice right away is that there are two ways that you can return a value from Python to Excel. The default way is to return a Python object reference to Excel. You can see this when there is a glyph on the left hand side of the cell. Clicking on it reveals an inspector that gives you a preview of the object.
1
12
9,148
The other way is to return the Python object by value. This will "spill" the contents of the Python object into a grid. In the typical case of returning a Pandas DataFrame, the values of the DataFrame will appear as separate cells in the grid.
I use it all the time as a watch window. And because Python cells participate in the dependency analysis in Excel, they will update every time the underlying Python object is recalculated.
1
11
7,540
A common question that has come up is why don't we run Python locally? There are three main reasons:
1. Running Python securely on a local machine is a really hard problem. We treat all Python code in the workbook as untrusted, so we execute it in a hypervisor-isolated container on Azure that does not have any outbound network access. Python code and the data that it operates on is sent to be executed in the container. The Microsoft-licensed Python environment in the container is provided by Anaconda and was prepared using their stringent security practices as documented here: docs.anaconda.com/free/anaco…
2. Sharing Excel workbooks with others is a really important scenario. We wanted to ensure that Python code in a workbook that you share will behave as you intended when someone else opens it; they wouldn't first need to install Python first.
3. We need to ensure that the Python in Excel feature always works for our customers. The value of Python is in its ecosystem of libraries, not just in providing a Python interpreter. But managing a local Python environment is challenging even for the most experienced developers. By running on Azure, we remove the need for users or their systems administrators to have to maintain a local installation of Python on every machine that uses the feature in their organization.
6
7
31
6,724





