Python in Excel: This Will Change Knowledge Science Endlessly

Python in Excel: This Will Change Data Science Forever
Picture by Creator


As a knowledge scientist working in trade, the previous 12 months has felt like a rollercoaster trip of recent tech breakthroughs and AI improvements. 

Instruments like ChatGPT, Notable, Pandas AI, and the Code Interpreter have saved me appreciable quantities of time in performing duties like writing, analysis, programming, and knowledge evaluation.

And simply once I thought issues couldn’t get any higher, Microsoft and Anaconda introduced the integration of Python into Excel!

Now you can write Python code to research knowledge, construct machine studying fashions, and create visualizations inside Excel spreadsheets.



The flexibility to put in writing Python code inside Excel will open new doorways for knowledge scientists and analysts.

After I obtained my first knowledge science job, I assumed I’d be doing most of my work in Jupyter Notebooks. To my shock, I ended up having to be taught to make use of Excel on my first day of the job, since higher administration, stakeholders, and shoppers most well-liked to interpret outcomes from spreadsheets.

The truth is, I’ve even created Tableau dashboards previously to current outcomes to shoppers, solely to finish up rebuilding the charts in Excel since they have been extra acquainted with the platform.

And this isn’t distinctive to my group. As of 2023, over one million corporations and 1.5 billion individuals around the globe use Excel. 

Many knowledge practitioners, like myself, discover themselves consistently switching between Python IDEs and Excel spreadsheets. We use the previous to construct machine studying fashions and analyze knowledge, and the latter to current our findings.

A Python-Excel integration will assist knowledge scientists and analysts streamline our workflows, by permitting us to carry out knowledge evaluation, modeling, and presentation inside a single platform.

Nonetheless not satisfied?

Let’s discover some potential use instances of this mix.



Listed here are some methods through which knowledge scientists can mix the performance of spreadsheets with Python’s huge array of libraries:


1. Knowledge Pre-Processing


If there may be one a part of my job I might gladly outsource, it’s knowledge preparation. This can be a cumbersome process that turns into extraordinarily time-consuming when utilizing native Excel capabilities.

With the brand new Python-Excel integration, customers can now import libraries like Pandas straight into Excel, and carry out superior filtering and knowledge aggregation straight inside Excel spreadsheets.

You possibly can merely sort “=PY” right into a cell in a spreadsheet and spotlight the information you need to analyze with Python, and a Pandas dataframe will likely be created for you. You possibly can proceed to group and manipulate this knowledge as you’d in a Jupyter Pocket book.

Right here is an instance of how one can create a Pandas dataframe in Excel:


Python in Excel: This Will Change Data Science Forever
Supply: Microsoft


2. Machine Studying


Whereas Excel gives fundamental instruments like linear regression and trendline becoming in charts, most machine-learning use instances require extra complicated modeling methods that transcend the native capabilities of Excel.

With this Python-Excel integration, customers can now construct and prepare superior statistical fashions inside Excel utilizing libraries like Scikit-Study. The mannequin outcomes might be visualized and introduced in Excel, bridging the hole between modeling and decision-making in a single platform.

Right here is a picture showcasing simply how easy it’s to construct a call tree classifier in Excel with Python:


Python in Excel: This Will Change Data Science Forever
Supply: Microsoft


3. Knowledge Evaluation


The method of analyzing knowledge in Excel might be painstaking – when working with a number of recordsdata without delay, customers want to repeat and paste knowledge manually, drag formulation throughout cells, and mix knowledge manually.

For instance, if I’ve 5 sheets of month-to-month gross sales knowledge that appears like this:




If I wished to seek out merchandise with greater than 100 models offered within the span of a month, I’d first need to manually copy knowledge from all sheets and paste it under the information within the first sheet. Then, I’d have to alter the date format and create a pivot desk.

Lastly, I’d have so as to add a filter to seek out the merchandise that match my standards.

Each time I get new gross sales knowledge in a distinct file or sheet, I would like to repeat and paste it manually.

This course of turns into more and more troublesome and error-prone as the quantity of information will increase.

As an alternative, the whole evaluation might be streamlined in Python utilizing the next strains of code:

# 1. Merge the information
df_merged = pd.concat([df_jan, df_feb], ignore_index=True)

# 2. Convert the date format
df_merged['Date'] = pd.to_datetime(df_merged['Date']).dt.strftime('%Y-%m-%d')

# 3. Compute the entire models offered for every product
grouped_data = df_merged.groupby('Product').agg({'Items Offered': 'sum'}).reset_index()

# 4. Determine merchandise that offered greater than 100 models
products_over_100 = grouped_data[grouped_data['Units Sold'] > 100]



Each time new knowledge is available in, I simply want to alter one line of code and re-run this system to get the specified end result. With a Python-Excel integration, I get to maximise effectivity whereas overseeing the whole knowledge evaluation workflow inside a single platform.


4. Knowledge Visualization


Though Excel itself gives a large number of visualization choices, the software continues to be considerably restricted within the sorts of charts you may construct. Charts like violin plots, heatmaps, and pair plots aren’t available in Excel, making it troublesome for knowledge scientists to signify complicated statistical relationships.

The flexibility to run Python code will enable Excel customers to make use of libraries like Matplotlib and Seaborn to create extra complicated, extremely customizable charts.


Python in Excel: This Will Change Data Science Forever
Supply: Microsoft



On the time of writing this text, the Python-Excel characteristic is simply out there by way of the Microsoft 365 Insider Program. It’s worthwhile to join and select the Beta Channel Insider stage to entry this characteristic, because it hasn’t been rolled out to the general public but.

When you be a part of the 365 Insider program, you’ll discover a Python part within the Formulation tab. You simply have to click on on “Insert Python.” You possibly can click on on it to start out writing your individual Python code. 

Alternatively, you may simply sort =PY into any cell to get began.


Python in Excel: This Will Change Data Science Forever
Supply: Anaconda



With the discharge of ChatGPT, together with plugins such because the Code Interpreter and Notable, many duties that after required sturdy technical experience have change into simpler to carry out.

That is very true for knowledge scientists and analysts – now you can add CSV recordsdata to ChatGPT, and it’ll clear, analyze, and construct fashions in your datasets.

In my view, the Python-Excel integration brings us one step nearer to the democratization of data science and analytics.

In fields like advertising and marketing and finance, trade specialists who work solely in Excel will now have the ability to execute Python code to research their knowledge with out even having to obtain a programming IDE.

The flexibility to work with knowledge in an interface they’re acquainted with, coupled with ChatGPT’s proficiency in writing code, will enable non-programmers to carry out knowledge science workflows and resolve issues with Python code.

In case you are an Excel person who doesn’t know find out how to code, this can be a nice alternative so that you can be taught Python programming inside an interface that you’re already snug with.
Natassha Selvaraj is a self-taught knowledge scientist with a ardour for writing. You possibly can join together with her on LinkedIn.

Leave a Reply

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