Using Python as a Data Source in Power BI

10 Comments

In our previous post, we installed and set up Python for use in Power BI. In this post, we will run a Python script and use that as a datasource in Power BI.

In Power BI Desktop, select Get Data, then More:

Select Python script and Connect:

This will open a Python script. Paste in the code from the previous example.

import pandas as pd
data = [['Alex',10],['Bob',12],['Clarke',13]]
df = pd.DataFrame(data,columns=['Name','Age'],dtype=float)
print (df)

It should look like below. Click OK:

Now click Load, then Transform Data to open it in the Power Query Editor:

We see the data has been loaded. Click Close and Apply:

In the Power BI Desktop report canvas, select the 2 fields from the df dataset. We see the Age and Name data is displayed. We can now use this Python data source with our Power BI Visuals.

In the next post, we will look at how to use Python to filter data in Power Query.

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

10 Responses to Using Python as a Data Source in Power BI

  1. Didn’t work, until this page i did all the steps as suggested, but i get the following error
    Details: “ADO.NET: A problem occurred while processing your Python script.
    Here are the technical details: Process must exit before requested information can be determined.”

  2. Looking for options to run the script in powerbi service. currently the refresh fails on service however i am able to successfully fetch data from using desktop.

  3. After loading the data thru python script, the data got loaded. But if I want to edit the script, can you help me how to do that, is there any option

Leave a Reply

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