Enhance Your Spreadsheets with Python Integration in Microsoft Excel

0
310

Is August 23rd, 2023 and you’re watching the code report Most developers will never admit it, but that game-changing new app they’re building probably could have just been an Excel spreadsheet. Excel, which came out in 1985, could be the single most important piece of software for our modern service-based economy.

Working with Excel formulas at my dead-end white-collar job is actually where I got my first taste of programming. I used formulas to figure out that I would never be able to own a house unless I got a higher-paying job. But you can’t do real programming with Excel. It is possible to hook it up with Visual Basic, but that’s just way too “Microsoft-y”.

Luckily, as of yesterday, Microsoft Excel will now support Python, a feature developed in collaboration with the creator of Python, Guido van Rossum, which is totally awesome. Here’s how it’ll work: In Excel, you have access to this new `=PYTHON` formula, which can run Python code against the data in your spreadsheet. For example, if you want to put your data into a Pandas data frame, you can now accomplish that by simply highlighting your data and running the corresponding Python code. Another huge benefit is the ability to use Python database packages like Seaborn and Matplotlib. More importantly though, it allows developers to write their own custom functions that can wrangle and clean real-world datasets, which can be fed to the hungry AI’s. In fact, you could even do machine learning directly in your spreadsheet with tools like scikit-learn. That’s pretty cool but don’t expect it to train deep learning models with tools like PyTorch and TensorFlow.

And that brings us to the one major caveat: the industry transformation. The key to success is your Python code does not run locally but instead runs in Microsoft’s Azure cloud. This will of course keep you safe from the dangers of spreadsheets and also from the hell that is managing your Python versions locally. They teamed up with Anaconda to create a standard runtime for running Python and Excel in Azure. However, being able to run Python locally offline is far more privacy-friendly and would be faster in most situations. The only problem is that Microsoft then wouldn’t have a product to sell you. You could switch to Linux and run LibreOffice, which has support for macros in both JavaScript and Python. It has had those features forever, but good luck convincing your boss that’s a good idea. It’s just too free and too open-source.

Python and Excel are going to be a game changer for the boring corporate world. Where the last few years, I’ve been using Google Sheets with Apps Script, which is one of the most underrated tools out there. It’s the same basic idea as Excel and Python but with JavaScript. I use it for a variety of business-related needs like it helps me automate the shipment of t-shirts and stickers to Fireship Pro members. And it can even be used to create custom menus and dialogues. However, Python is a far more powerful language when it comes to data analysis. What that means is that virtually every white-collar worker will now be able to generate some Python code with ChatGPT, copy and paste it into Excel, and solve the vast majority of common problems out there.

Microsoft will be the one running and hosting this code. They already have the most powerful AI models, and those models will only grow bigger and stronger over time. Nobody’s even close to Microsoft right now in the AI race, and that’s a result of their developer-friendly strategy, which can be broken down into three steps. First, they embrace the developer community. Developers, developers, developers, developers, develop first, developers, then extend developers with awesome new features and tools. Then I seem to have forgotten what the third step is, but this has been the code report. Thanks for watching, and I will see you in the next one.