Boost Data Analytics: Integrate Python Scripts in Power BI Desktop

Introduction

You can run Python scripts directly in Power BI Desktop and import the resulting datasets into a Power BI Desktop data model. From this model, you can create reports and share them on the Power BI service. Now, users can seamlessly execute Python scripts directly within Power BI, tapping into a vast array of machine learning frameworks and data science libraries. Join the thriving community of open-source developers as we explore the integration of Python into Power BI, unlocking new potentials in data analysis and visualization.

Prerequisite

To work with Python in Power BI, we need to have the following prerequisites.

  1. Python runtime installed: The execution runtime on which the Python scripts will be executed.
  2. Install the required libraries: We need to install Pandas and Seaborn to work with.
  3. Visual Studio code(optional): A code editor to efficiently write Python scripts. This is optional as you can also write Python scripts in the Power BI Script editor. However, I recommend using a code editor as it supports syntax highlighting and other essential features.
  4. Updating Power BI settings: Additionally, we need to update the settings in the Power BI to be able to work with Python in Power BI.

Enable Python scripting

To enable Python scripting in Power BI.

  1. In Power BI Desktop, selectFile>Options and Settings>Options>Python scripting. The Python script options page appears.Python Scripting
  2. If necessary, supply or edit your local Python installation path under Detected Python home directories. In the preceding image, the Python’s installation local path is C:\Python. If you have more than one local Python installation, make sure to select the one that you want to use.
  3. SelectOK.
  4. Install necessary libraries pip install pandas pip install matplotlib.

Now you are ready to run the Python scripts in Power BI.

Conclusion

This article has guided us through integrating Python with Power BI, showcasing Python’s status as a leading open-source programming language widely adopted in data science and machine learning domains. By incorporating Python into Power BI, we’ve demonstrated how to surpass the tool’s standard functionalities, thereby significantly improving Power BI’s performance and capabilities.

About the Author:

Dr. S. Gomathi is an esteemed Microsoft Most Valuable Professional (MVP) and a Microsoft Certified Trainer (MCT), renowned for her expertise in data analytics and Business Central and Power Platform. She holds multiple certifications, including Microsoft Certified Data Analyst Associate and Power Platform Solution Architect Expert, alongside her role as a Google for Education Certified Trainer.

With over 13 years of experience in academia and industry, Dr. Gomathi has distinguished herself as a skilled trainer and professor, specializing in Power App, Power BI, Business Central, Data Science, ETL tools, and Machine Learning.

Her accolades include several Asia Books of Record, India Books of Record, “Young Scientist” and “Women Scientist” awards, highlighting her contributions to the field of research and data analytics.

As a holder of 6 national and international patents, she continues to inspire and lead in the ever-evolving world of technology and analytics.

Reference:

Gomathi, S. (2024). Boost Data Analytics: Integrate Python Scripts in Power BI Desktop. Available at: https://www.c-sharpcorner.com/article/boost-data-analytics-integrate-python-scripts-in-power-bi-desktop/ [Accessed: 22nd February 2024].

Share this on...

Rate this Post:

Share: