Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello, I was running the following Python script:
import pandas as pd
df = pd.DataFrame({
'Fname':['Harry','Sally','Paul','Abe','June','Mike','Tom'],
'Age':[21,34,42,18,24,80,22], 'Weight': [180, 130, 200, 140, 176, 142, 210],
'Gender':['M','F','M','M','F','M','M'],
'State':['Washington','Oregon','California','Washington','Nevada','Texas','Nevada'],
'Children':[4,1,2,3,0,2,0], 'Pets':[3,2,2,5,0,1,5] })
print (df)
the script cretaed the data frame without any error but when Power BI try to load the table in the model (connection to the model) I receive the following error:
"Failed to save modifications to the server. Error returned: 'Expression in partition 'n/a' in table 'n/a' references unknown variable or function 'Python.Execute'. '."
I have installed:
This is the Session Diagnostics from Power BI Desktop:
Feedback Type:
Frown (Error)
Timestamp:
2020-03-29T12:55:05.3504335Z
Local Time:
2020-03-29T08:55:05.3504335-04:00
Session ID:
fd38f850-8e8b-44f3-a910-1eec36fa43be
Release:
March 2020
Product Version:
2.79.5768.721 (20.03) (x64)
OS Version:
Microsoft Windows NT 10.0.18363.0 (x64 en-US)
CLR Version:
4.7 or later [Release Number = 528040]
Peak Virtual Memory:
38.5 GB
Private Memory:
644 MB
Peak Working Set:
766 MB
IE Version:
11.719.18362.0
User ID:
6fa195ba-dfc3-4ffb-876e-6fccdd8617ea
Workbook Package Info:
1* - en-US, Query Groups: 0, fastCombine: Enabled, runBackgroundAnalysis: True.
Telemetry Enabled:
False
Snapshot Trace Logs:
C:\Users\vicen\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot763307589.zip
Model Default Mode:
Empty
Model Version:
PowerBI_V1
Is Report V3 Models Enabled:
True
Performance Trace Logs:
C:\Users\vicen\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip
Enabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_SpanishLinguisticsEnabled
PBI_NewWebTableInference
PBI_qnaLiveConnect
PQ_AIInsightsFunctionBrowser
PBI_realTimeRefresh
PBI_showMinervaRibbon
PBI_showMinervaViewNavigator
PBI_v3Models
PBI_decompositionTree
PBI_themeDialog
PBI_hierarchicalSlicerCreation
Disabled DirectQuery Options:
TreatHanaAsRelationalSource
Cloud:
GlobalCloud
DPI Scale:
100%
Supported Services:
Power BI
Formulas:
section Section1;
shared df = let
Source = Python.Execute("import pandas as pd #(lf)df = pd.DataFrame({ #(lf) 'Fname':['Harry','Sally','Paul','Abe','June','Mike','Tom'], #(lf) 'Age':[21,34,42,18,24,80,22], #(lf) 'Weight': [180, 130, 200, 140, 176, 142, 210], #(lf) 'Gender':['M','F','M','M','F','M','M'], #(lf) 'State':['Washington','Oregon','California','Washington','Nevada','Texas','Nevada'],#(lf) 'Children':[4,1,2,3,0,2,0],#(lf) 'Pets':[3,2,2,5,0,1,5] #(lf)}) #(lf)print (df) "),
df1 = Source{[Name="df"]}[Value],
#"Changed Type" = Table.TransformColumnTypes(df1,{{"Fname", type text}, {"Age", Int64.Type}, {"Weight", Int64.Type}, {"Gender", type text}, {"State", type text}, {"Children", Int64.Type}, {"Pets", Int64.Type}})
in
#"Changed Type";
shared #"df (2)" = let
Source = Python.Execute("import pandas as pd #(lf)df = pd.DataFrame({ #(lf) 'Fname':['Harry','Sally','Paul','Abe','June','Mike','Tom'], #(lf) 'Age':[21,34,42,18,24,80,22], #(lf) 'Weight': [180, 130, 200, 140, 176, 142, 210], #(lf) 'Gender':['M','F','M','M','F','M','M'], #(lf) 'State':['Washington','Oregon','California','Washington','Nevada','Texas','Nevada'],#(lf) 'Children':[4,1,2,3,0,2,0],#(lf) 'Pets':[3,2,2,5,0,1,5] #(lf)}) #(lf)print (df) "),
df1 = Source{[Name="df"]}[Value],
#"Changed Type" = Table.TransformColumnTypes(df1,{{"Fname", type text}, {"Age", Int64.Type}, {"Weight", Int64.Type}, {"Gender", type text}, {"State", type text}, {"Children", Int64.Type}, {"Pets", Int64.Type}})
in
#"Changed Type";
shared #"df (3)" = let
Source = Python.Execute("import pandas as pd #(lf)df = pd.DataFrame({ #(lf) 'Fname':['Harry','Sally','Paul','Abe','June','Mike','Tom'], #(lf) 'Age':[21,34,42,18,24,80,22], #(lf) 'Weight': [180, 130, 200, 140, 176, 142, 210], #(lf) 'Gender':['M','F','M','M','F','M','M'], #(lf) 'State':['Washington','Oregon','California','Washington','Nevada','Texas','Nevada'],#(lf) 'Children':[4,1,2,3,0,2,0],#(lf) 'Pets':[3,2,2,5,0,1,5] #(lf)}) #(lf)print (df) "),
df1 = Source{[Name="df"]}[Value],
#"Changed Type" = Table.TransformColumnTypes(df1,{{"Fname", type text}, {"Age", Int64.Type}, {"Weight", Int64.Type}, {"Gender", type text}, {"State", type text}, {"Children", Int64.Type}, {"Pets", Int64.Type}})
in
#"Changed Type";
Solved! Go to Solution.
Hi Lewis,
I know the Python Script work, but when I try en Power BI it give me a error...
Yesterday I fixed the problem. I uninstalled and install again: Python, Anaconda, Power BI and VS Code, after that the Python program work in Power BI…
Thank you for you help...
I think the main issue is here in the error message...
TypeError: from_bounds() takes 4 positional arguments but 6 were given
The line that Python was trying to execute was this:
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
Maybe get rid of the 0's?
Are you trying to make a visual or uploading data using python script?
Have you tested out the code in an IDE?
Hi Lewis,
I know the Python Script work, but when I try en Power BI it give me a error...
Yesterday I fixed the problem. I uninstalled and install again: Python, Anaconda, Power BI and VS Code, after that the Python program work in Power BI…
Thank you for you help...
Hi @vmerida ,
As tested, I can import your python script successfully.
let
Source = Python.Execute("import pandas as pd#(lf)#(lf)df = pd.DataFrame({#(lf)#(lf)'Fname':['Harry','Sally','Paul','Abe','June','Mike','Tom'],#(lf)#(lf)'Age':[21,34,42,18,24,80,22], 'Weight': [180, 130, 200, 140, 176, 142, 210],#(lf)#(lf)'Gender':['M','F','M','M','F','M','M'],#(lf)#(lf)'State':['Washington','Oregon','California','Washington','Nevada','Texas','Nevada'],#(lf)#(lf) 'Children':[4,1,2,3,0,2,0], 'Pets':[3,2,2,5,0,1,5] })#(lf)#(lf)print (df)"),
df1 = Source{[Name="df"]}[Value],
#"Changed Type" = Table.TransformColumnTypes(df1,{{"Fname", type text}, {"Age", Int64.Type}, {"Weight", Int64.Type}, {"Gender", type text}, {"State", type text}, {"Children", Int64.Type}, {"Pets", Int64.Type}})
in
#"Changed Type"
Maybe you can try to use my M code.
My Power BI version: 2.79.5768.663 64-bit (March 2020)
My python: python38-32
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Lionel,
I know the Python Script work, but when I try en Power BI it give me a error...
Yesterday I fixed the problem. I uninstalled and install again: Python, Anaconda, Power BI and VS Code, after that the Python program work in Power BI…
Thank you for you help…
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
82 | |
67 | |
61 | |
46 | |
45 |