Way Using Python in Excel is a very interesting and useful topic for those who want to enhance their ability to work with data. By combining Python and Excel, you can take advantage of both tools and solve many problems in your work.
Join the channel Telegram belong to AnonyViet ???? Link ???? |
Introduction to Python and Excel
Python and Excel are two powerful and popular tools for working with data. Python is a general-purpose programming language that is easy to learn, has a clear syntax, and has many libraries that support data-related tasks, such as analysis, processing, visualization, and machine learning.
Excel is a spreadsheet application that allows users to enter, store, sort, filter, calculate and represent data according to built-in formulas and functions.
Python has the advantages of flexibility, extensibility, automation, and high performance, but also has the disadvantage of being difficult to communicate with non-specialists, requiring programming skills, and lacking compatibility with other applications. .

Excel has the advantage of being easy to use, friendly, interactive, and compatible with other applications, but also has the disadvantages of limitations, manual work, errors, and low performance.
Benefits of using Python in Excel
By using Python in Excel, you can:
- Read, write, add, delete, edit data in Excel with Python
- Use Python libraries to analyze and visualize data in Excel
- Create custom Python functions and call them from Excel
- Automate Repetitive Tasks in Excel with Python
- Increase performance and reduce errors when working with data in Excel with Python
Work seamlessly
You can now perform advanced data analysis in the familiar Excel environment by accessing Python directly from the Excel toolbar with no setup or installation required. Using Excel and Power Query’s built-in connections, you can easily bring external data into Python workflows in Excel.

Microsoft is partnering with Anaconda, a leading Python repository used by tens of millions of data practitioners worldwide, leveraging Anaconda Distribution that runs on Azure, including the most popular Python libraries like pandas for data manipulation, statsmodels for advanced statistical modeling, and Matplotlib and seaborn for data visualization.
Cooperation is easy
You can share Python spreadsheets and analysis in Microsoft Teams and Microsoft Outlook. It’s easy for you to work as a team with comments and @ mentions. Plus, your colleagues can refresh their Python analysis in Excel for up-to-date information, even if they don’t have Python enabled.
Automatic security

Protecting your data is a top priority for Microsoft, so they’ve built security and privacy into the core of their design for Python in Excel.
Python in Excel runs on the Microsoft cloud with enterprise-grade security as an M365 connected experience.
How to Setup Python in Excel
Python in Excel is rolling out to Public Preview for participants Microsoft 365 Insiders program on the Beta channel. This feature will be rolled out to Windows first, starting with version 16818, and then to other platforms in the future.

How to use Python in Excel
Python Functions in Excel
Python is written with a new function in Excel, PY.
You just need to type =PY and then press the TAB key, the formula bar will switch to Python mode

Or you can also switch the formula bar to Python mode by clicking Formulas tab > Insert Python > Custom Python Formula

How to Add Python Libraries to Excel
To add the Python library to Excel, you enter the command as:
import [LibraryName] as [LibraryShortName]
For example in the image below, I have imported Pandas, Seaborn and Matplotlib

Then press Ctrl+Enter to complete the formula
Tip: if the cell doesn’t show the Python Object icon, select it from the drop-down list next to the formula bar

Epilogue
In this article, I showed you how to Using Python in Excel. Hopefully this article will help you improve your ability to work with data in Python and Excel, and open up many new opportunities for you in the future.