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.
- Python runtime installed: The execution runtime on which the Python scripts will be executed.
- Install the required libraries: We need to install Pandas and Seaborn to work with.
- 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.
- 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.
- In Power BI Desktop, selectFile>Options and Settings>Options>Python scripting. The Python script options page appears.
- 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.
- SelectOK.
- 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.