Using Python as a Data Source in Power BI


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.



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

carldesouza.comLinkedIn Twitter | YouTube


5 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.”

Leave a Reply

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