Skip to main content

Power BI

New

Python editor overhaul - PowerBI

Vote (1) Share
Henry Post's profile image

Henry Post on 20 Nov 2024 19:05:35


PowerBI has big quality issues with the Python editor. I'm used to PyCharm/IDLE/the Python REPL, and found it very hard to diagnose Python scripts, interpret errors, or even make small changes to them in PowerBI.


1. When you go to "Get Data > More > Python Script", you are only allowed to paste a Python script in. You can't use a file on disk. PowerBI forces you to embed a static script in PowerBI. This is annoying because it'd be nice to maintain a file-based repo of Python scripts, instead of embedding them in the .pbix file.


2. If I want to edit the imported Python script, you get a terribly hard to read block of text:


let

  Source = Python.Execute("import pandas as pd#(lf)#(lf)# Example data#(lf)data = {#(lf)  'Category': ['Electronics', 'Electronics', 'Furniture', 'Furniture', 'Office Supplies', 'Office Supplies'],#(lf)  'Sub-Category': ['Phones', 'Laptops', 'Chairs', 'Tables', 'Paper', 'Binders'],#(lf)  'Sales': [5000, 7000, 3000, 4000, 1000, 2000],#(lf)  'Profit': [1500, 2000, 500, 800, 200, 600],#(lf)  'Date': ['2024-01-01', '2024-02-01', '2024-01-01', '2024-02-01', '2024-01-01', '2024-02-01']#(lf)}#(lf)#(lf)# Create the DataFrame#(lf)df = pd.DataFrame(data)#(lf)#(lf)# Convert Date column to datetime#(lf)df['Date'] = pd.to_datetime(df['Date'])#(lf)#(lf)print(df)#(lf)"),

  df1 = Source{[Name="df"]}[Value]

in

  df1


3. Error logs have no history: If I have a Python error, I can't easily diagnose it from within PowerBI or debug it. I have to open a separate text editor, hope that I saved my original Python script, run it in my own REPL, and also copy the error to an external text editor.


4. No stdout: If my script prints to stdout, I can't view it.


I could go on, but I think the main point stands: Debugging or editing PowerBI Python scripts is really painful. Even an IDLE-like interface would be amazingly useful.