Skip to main content

Anaconda Code First Impressions: Running Python in Excel

Recently, I had the chance to explore Anaconda Code, an exciting Excel add-in that brings Python functionality directly into your spreadsheets. In this post, I’ll share my first impressions and walk through a practical example of how it works.

What is Anaconda Code? #

Anaconda Code is an Excel add-in that uses PyScript and Pyodide in the background, allowing you to run Python code locally within Excel. The best part? Once set up, you don’t need an internet connection to use it, as everything runs locally using WebAssembly.

Getting Started #

To get started with Anaconda Code, you need to download it from the Microsoft Add-ins store:

  1. Go to the Add-ins section in Excel
  2. Click on “Get Add-ins” or “Find more add-ins”
  3. Search for “Anaconda” in the Microsoft AppSource
  4. Download the “Anaconda Toolbox”
  5. Create an Anaconda Cloud account (free tier is sufficient)

Once installed, you’ll be able to create Anaconda Code cells directly in Excel.

Practical Example: Percentile Calculation #

For my demonstration, I wanted to implement a function that infers a third percentile value based on two known percentiles. This is particularly useful in my field for reserves estimation, where we work with P10, P50, and P90 values.

The Use Case #

Imagine you have two known percentile values, and you want to calculate a third one. For example:

  • Known: P50 = 10 million
  • Known: P10 = 15 million
  • Unknown: P90 = ?

Setting Up the Environment #

Before loading the environment, you’ll want to configure which Python packages you need. Anaconda Code comes with several packages by default, including:

  • NumPy
  • Matplotlib
  • SciPy
  • And many more

For my example, these default packages were sufficient.

Creating Python Cells #

The process of creating Python cells in Excel is straightforward:

  1. Add a new PyScript cell from the Anaconda Code add-in

  2. Map Excel ranges to Python variables - You can do this either interactively or by clicking on cell ranges:

    • p1 → First percentile value
    • v1 → First value
    • p2 → Second percentile value
    • v2 → Second value
    • unknown_percentile → The percentile you want to calculate
  3. Write your Python code - Copy or write your analysis code directly in the cell

  4. Run and see results - The code executes locally and updates in real-time

Interactive Results #

One of the coolest features is how interactive everything becomes. When I changed the input values in Excel:

  • From P50 to P90
  • Adjusting the known percentile values

The Python code re-executed automatically, updating both the calculated values and any plots I had created. The results appeared both as numerical outputs and as visualizations generated by Matplotlib.

Key Observations #

Pros #

Local Execution: All the Python code runs locally using Pyodide (Python compiled to WebAssembly). This means your calculations happen inside the browser/Excel window, not on a remote server.

Rich Library Support: Anaconda Code includes a good selection of data science libraries. When you check the available libraries in Pyodide, you’ll find popular ones like scikit-learn, making it suitable for basic machine learning tasks.

Real-time Updates: Changes to input values automatically trigger recalculation, making it very interactive.

Visualization Support: Matplotlib plots render directly in Excel, providing visual feedback alongside numerical results.

Questions and Considerations #

Cloud Account Requirement: One thing I’m still unclear about is why an Anaconda Cloud account is required. Since the code runs locally via WebAssembly, I’m not sure where the code is being hosted or why cloud authentication is necessary. If anyone knows the answer, please let me know in the comments!

Use Cases: This tool opens up exciting possibilities for people who aren’t data scientists but want to:

  • Perform analyses not available in Excel’s built-in functions
  • Create custom plots and visualizations
  • Run basic machine learning models
  • Automate complex calculations

Final Thoughts #

Excel is the most widely used data analysis tool in the world, used by millions who aren’t professional data scientists. Anaconda Code bridges the gap between Excel’s accessibility and Python’s powerful analytical capabilities.

For reservoir engineers, financial analysts, scientists, and anyone who works with data in Excel but needs more advanced analytical tools, this add-in could be a game-changer. The ability to combine Excel’s familiar interface with Python’s computational power—all running locally—is impressive.

Here’s a demo of Anaconda Code in action:

I’m excited to explore more use cases for Anaconda Code. If you’ve used it or have ideas for interesting applications, I’d love to hear about them!